【发布时间】:2020-11-27 02:57:52
【问题描述】:
在数据表服务器端实现列过滤器时遇到问题。过滤器列出现,但不起作用。我查看了许多参考资料,如以下链接,但仍然无法解决我的问题。
https://datatables.net/examples/api/multi_filter.html
https://datatables.net/extensions/fixedcolumns/examples/styling/col_filter.html
jquery datatables server side - filter column on top
这是迄今为止我尝试过的代码。
$('#table tfoot th').each( function (i) {
var title = $('#table thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" data-index="'+i+'" />' );
} );
table = $('#table').DataTable({
aLengthMenu: [
[15, 25, 50, 100, 200, -1],
[15, 25, 50, 100, 200, "All"]
],
iDisplayLength: 15,
"processing": true,
"serverSide": true,
"ordering": false,
"searching": true,
"scrollY": true,
"scrollX": true,
"order": [],
"ajax": {
"url": "<?php echo site_url('drawing/ajax_list_welding_plan')?>",
"type": "POST",
"data": function ( data ) {
data.drawing_no = $('#drawing_no_table').val();
data.project_no = $('#project_table').val();
data.drawing_title = $('#drawing_title_table').val();
data.document_title = $('#document_title_table').val();
data.client = $('#client_table').val();
}
},
"columnDefs": [
{
"targets": [ -1 ],
"orderable": false,
},
{
"targets": [ -2 ],
"orderable": false,
},
{
"targets": [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21], // your case first column
"className": "text-center",
"width": "4%"
},
],
});
$( table.table().container() ).on( 'keyup', 'tfoot input', function () {
table
.column( $(this).data('index') )
.search( this.value )
.draw();
} );
【问题讨论】:
标签: jquery codeigniter datatables