【发布时间】:2015-04-09 09:00:10
【问题描述】:
我正在使用带有 bootstrap3 的数据表。我想在单击按钮后应用过滤器。但是当我单击按钮时,它给了我TypeError: oTable.settings is not a function 错误。我的数据表版本是1.10.6,yadcf 版本是0.8.7
这是我的代码
function init_datatable(table_id, records) {
// console.log('init table',$.parseJSON(records));
var oTable = $(table_id).dataTable({
aaData: $.parseJSON(records),
"sPaginationType": "bootstrap",
"bFilter": false,
"bInfo": false,
"sPageButtonActive": "active",
"aaSorting": [[0, 'desc']],
"bDeferRender": true,
"sDom": '<"top"if>rt<"bottom"lp><"clear">',
"aLengthMenu": [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"] // change per page values here
],
"iDisplayLength": 10,
"oLanguage": {
"sEmptyTable": "No data available"
},
"aoColumnDefs": [{
"aTargets": [0],
"bVisible": false,
"bSearchable": false
},
{
"bSortable": false,
"aTargets": [-1], // <-- gets last column and turns off sorting
"mData": null,
"mRender": function(data, type, full) {
return '<a data-original-title="Edit" id="edit_' + full[0] + '" data-placement="top" class="btn btn-xs btn-teal tooltips edit" href="javascript:void(0)"><i class="fa fa-edit"></i> Edit</a>';
}
}]
});
// .yadcf([
// {column_number: 1}
// ]);
$(table_id + '_wrapper .dataTables_length select').addClass("m-wrap");
$(table_id + '_wrapper .dataTables_length select').select2();
return oTable;
}
这是应用列过滤器的代码
var pTable = init_datatable('#tbl_sample', data);
function apply_column_filter() {
yadcf.init(pTable, [
{column_number: 1}
]);
}
“init_datatble 函数中的注释代码正在工作。但是当我使用 init 时它给了我错误
【问题讨论】: