Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery数据表和ColVis插件出错;无法读取属性';瑞士';“未定义”的定义;_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript JQuery数据表和ColVis插件出错;无法读取属性';瑞士';“未定义”的定义;

Javascript JQuery数据表和ColVis插件出错;无法读取属性';瑞士';“未定义”的定义;,javascript,jquery,datatables,Javascript,Jquery,Datatables,使用带有ColVis插件的jquery.datatables插件,我在删除列时收到以下错误: “无法读取未定义的属性'sWidth'。”。我还没有在网上找到这个错误的解决方案 我不确定是什么原因导致了这个错误,尽管我确实有一个修复程序,我想发布给遇到这个问题的其他人 我使用的是来自的jquery.datatables 1.9.4。在datatables的第3255行源代码是这行代码: nThs[i].style.width = o.aoColumns[iVis].sWidth; 在本例中,o.

使用带有ColVis插件的jquery.datatables插件,我在删除列时收到以下错误:

“无法读取未定义的属性'sWidth'。”。我还没有在网上找到这个错误的解决方案

我不确定是什么原因导致了这个错误,尽管我确实有一个修复程序,我想发布给遇到这个问题的其他人


我使用的是来自的jquery.datatables 1.9.4。

在datatables的第3255行源代码是这行代码:

nThs[i].style.width = o.aoColumns[iVis].sWidth;
在本例中,o.aoColumns[iVis]为空,因为索引表示的列刚刚被隐藏。看起来我遇到了一个插件创建者没有预料到的困境。上面的代码被调用以响应内部datatables事件,该事件由ColVis在隐藏列时调用的方法触发。解决此问题所需的全部工作是将上述代码更改为:

var column = o.aoColumns[iVis];

if(column != null) {
    nThs[i].style.width = o.aoColumns[iVis].sWidth;
}

不幸的是,这需要编辑核心插件代码,但我会在错误报告中,希望他们很快解决这个问题。同时,希望这能帮助人们寻找解决方法。

搜索
a.aoColumns[D]。sWidth
,替换

 var column = a.aoColumns[D];if(column != null) {c.style.width=a.aoColumns[D].sWidth} 

当中的列数

<thead></thead>
$('#ls-table').DataTable($.extend({}, window.coonDataTableOptions, {
    columns: [
         <here>
    ]
 }));

与中的列数不同

<thead></thead>
$('#ls-table').DataTable($.extend({}, window.coonDataTableOptions, {
    columns: [
         <here>
    ]
 }));
$('#ls table').DataTable($.extend({},window.coonDataTableOptions{
栏目:[
]
}));

这种错误仅仅是由于在

…数据表(。。。 “列”:。。。 )

与已定义的HTML页面不匹配,列数为

。。 ..

使用
$(“thead”).empty()
mainTable.clear().destroy().draw()之后

数据表中的问题;一旦jquery中的数据加载到html5“thead”数据表jquery,例如
mainTable.clear().destroy().draw()
无法删除AD上的数据,因此解决方案是使用jquery
.empty()
将其删除


您的欢迎:)

在我的情况下,我忘记在每行的最后一列添加额外的{“data”:null},{“data”:null}用于我的按钮编辑和删除。在添加我的按钮后,User1398619共享了正确的答案。