【发布时间】:2014-10-07 10:46:54
【问题描述】:
我的数据表有问题。我无法在表格容器外的输入中启用 bFilter。有一个代码可以初始化我的数据表。
var table = $('#table-perms-users').DataTable( {
"scrollY": tableHeight + "px",
"scrollX": "100%",
"scrollXInner": "100%",
"bScrollCollapse": true,
"bSort" : true,
"bInfo": false,
"bFilter": false,
"bPaginate": false,
"columns": [
{ "orderDataType": "dom-last-name"},
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" },
{ "orderDataType": "dom-checkbox" }
]
} );
我尝试在输入的 keyup 事件上使用函数 fnFilter() 启用过滤器。看起来是这样的:
$('#dTSearch').keyup(function(){
table.fnFilter($(this).val());
});
但我可以在控制台上看到一条错误消息:
Uncaught TypeError: undefined is not a function (index):10086(anonymous function)
(索引):10086jQuery.event.dispatch jquery.1.11.1.js?t=1402046180:4641elemData.handle
也许有人可以回答我做错了什么?看起来它没有看到 var 表或没有找到函数 fnFilter。也许我在定义我的数据表时有一些错误?
【问题讨论】:
标签: javascript jquery datatable