$('#myDataTable')。dataTable()抛出异常

时间:2016-04-07 15:53:30

标签: jquery datatables

我正在使用DataTables 1.10.7版本。我正在使用下面给出的脚本创建数据表:

<script data-for="myDataTable" type="application/json">
{"x":{"data":    
[["+jsonIDList+"],["+jsonLocations+"],["+jsonScore+"]],"container":"
ID  Location    Score
","options":{"pageLength":15,"autoWidth":true,"columnDefs":    
[{"className":"dt-right","targets":2}],"order":    
[],"orderClasses":false,"orderCellsTop":true,"lengthMenu":    
[10,15,25,50,100]},"callback":null,"filter":"top","filterHTML":"
<tr>              <td data-type=\"character\" sType=\"html\" 
style=\"vertical-align:             top;\">
</td> <td data-type=\"character\" style=\"vertical-align: top;\">
</td> <td data-type=\"number\" style=\"vertical-align: top;\">
</td></tr>"},"evals":[]}
</script>

这适用于过滤和搜索。我需要添加一个新的重置按钮,单击该按钮时需要将搜索和过滤条件重置为默认值。我在重置按钮时使用以下代码

<button type="button" onclick="resetmyDataTable();" class="btn btn-default">Reset datatable</button> is clicked
function resetmyDataTable() {
    var table = $('#myDataTable').dataTable();
    // Perform a filter
    table.fnFilter('Win');
    table.fnFilter('Trident', 0);
    // Remove all filtering
    table.fnFilterClear();
}

$('#myDataTable').dataTable()正在抛出异常:

  

无法获取未定义或空引用的属性“nTable”

以下是异常期间的调用堆栈:

w - exception line: h(a.**nTable**).trigger(b,e)
I
Anonymous function
each
each
m()
resetmyDataTable()

w函数有异常:

function w(a,b,c,e){var d=[];b&&(d=h.map(a[b].slice().reverse(),function(b)    
{return b.fn.apply(a.oInstance,e)}));null!==c&&    
(b=h.Event(c+".dt"),h(a.nTable).trigger(b,e),d.push(b.result));return d}

感谢您的任何帮助。

0 个答案:

没有答案