[英]Error : “cannot read property 'nodename' of undefined” While converting html Table
I am trying to convert an HTML Table to KendoGrid but getting an error while executing this我正在尝试将 HTML 表转换为 KendoGrid,但在执行此操作时出错
$("#ReportExport").kendoGrid({ toolbar: ["excel"], filterable: { mode: "row" }, pageSize: 25, sortable: true, columnMenuInit(e) { e.container.find('li[role="menuitemcheckbox"]:nth-child(1)').remove(); e.container.find('li[role="menuitemcheckbox"]:nth-child(4)').remove(); }, columnMenu: { filterable: false }, reorderable: true, resizable: true, pageable: { alwaysVisible: true, pageSizes: [25, 100] }, });
and the console says this Uncaught TypeError: Cannot read property 'nodeName' of undefined at N (kendo.all.js:7692)控制台说这个 Uncaught TypeError: Cannot read property 'nodeName' of undefined at N (kendo.all.js:7692)
This error can be due to the element not being available when the script tries to access it.此错误可能是由于脚本尝试访问该元素时该元素不可用。
You can try to insert your code on a document.ready function to make sure your DOM is loaded or check if the element is available before running your code.您可以尝试在 document.ready function 上插入代码,以确保您的 DOM 已加载或在运行代码之前检查该元素是否可用。
I got this one.我得到了这个。 Actually I was unaware of the difference between
$("#GridName").KendoGrid()
and $("#GridName").data('kendoGrid')
.实际上我不知道
$("#GridName").KendoGrid()
和$("#GridName").data('kendoGrid')
。 First one basically initialize the grid.Later on,if you want to operate the grid,You have to get it first in a variable by using second method.第一个基本上是初始化网格。后面如果要操作网格,你必须先用第二种方法在一个变量中获取它。 So the problem lies here
所以问题出在这里
columnMenuInit(e) { e.container.find('li[role="menuitemcheckbox"]:nth-child(1)').remove(); e.container.find('li[role="menuitemcheckbox"]:nth-child(4)').remove(); }
Since the method I was using is for initialization,so grid was unable to perform the required functionality.由于我使用的方法是用于初始化,因此网格无法执行所需的功能。 Thanks to Diogo Peres for giving me right direction.
感谢 Diogo Peres 给了我正确的方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.