我有带数据表的表过滤器,但是为什么过滤器不会返回数据表中的所有数据?
完整的jquery:
$(document).ready( function () {
//table definition
var table = $('#tbl').DataTable({
processing: true,
serverSide: true,
"filter": true,
"ajax": {
"url": '/member/serverSide/',
"type": "GET"
},
//get data from ajax
columns: [
{ data: 'Expedisi', name: 'Expedisi', "dropdown" : true},
{ data: 'Type', name: 'Type' },
{ data: 'Moda', name: 'Moda' },
{ data: 'Asal', name: 'Asal' },
{ data: 'Tujuan', name: 'Tujuan' },
{ data: 'ETD', name: 'ETD' },
{ data: 'Weight', name: 'Weight' },
{ data: 'Price', name: 'Price' },
{ data: 'Minimal', name: 'Minimal' },
{ data: 'Price Minimal', name: 'Price Minimal' },
{ data: 'Price Per Point', name: 'Price Per Point' },
{ data: 'action', name: 'action', orderable: false, searchable: false}
],
initComplete......,
"order": [[ 4, "asc" ], [ 10, "asc" ]],
"columnDefs": [{
"targets": [ 0,4,10 ], //first column / numbering column
"orderable": true, //set not orderable
},
]
});
});
这是我用于创建过滤器的Jquery代码:
initComplete: function () {
this.api().columns([0]).every(function () {
var column = this;
var select = $('#xped').appendTo($('#tabel')).on( 'change', function () {
var val = $(this).val();
column.search( this.value ).draw();
});
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option>'+d+'</option>' )
});
});
}
这是我的表格视图的屏幕截图: enter image description here