我有这个数据表,我试图使用YADCF来过滤我的结果。该表工作正常,过滤器UI完美加载,但是当我选择日期时,它会过滤所有结果,即使我删除选择,也可以过滤'过滤器'保持适用,直到我刷新页面。此错误适用于所有yadcf过滤器,不仅适用于range_date。
$(document).ready(function() {
var active = $('#active').DataTable( {
global: false,
"dom": 'f<"toolbar">rtilp',
"processing": true,
"serverSide": true,
"ajax": {
"url": "processing_active.php"
},
"order": [[ 4, "desc" ]]',[ 2, "asc" ],[ 10, "desc" ]],
"deferRender": true,
"lengthMenu": [[55, 155, 250, -1], [55, 155, 250, 'All']],
"columns": [
{
"class": "details-control",
"orderable": false,
"data": null,
"defaultContent": "",
"visible": false
},
{ "data": "loadNumber","width": "8em"},
{ "data": "driverName","width": "10em"},
{ "data": "truckNum","width": "5em"},
{ "data": "puDate","width": "9em"},
{ "data": "puCity", "width": "10em" },
{ "data": "puState", "width": "1em" },
{ "data": "regStatus"},
{ "data": "deCity", "width": "10em" },
{ "data": "deState", "width": "1em"},
{ "data": "deDate","width": "9em"},
{ "data": "loadRate","width": "7em"},
{ "data": "confNumber", "width" : "9em"},
{ "data": "dispatcherName", "width": "10em"},
{ "data": "smallStatus"}
]
});
$(document).ready(function() {
$('#active').dataTable().yadcf([
{
column_number: 4,
filter_type: "range_date",
}
]);
});
答案 0 :(得分:1)
您需要在服务器端编写过滤逻辑,因为当使用带服务器端处理的数据表时,所有过滤逻辑也在服务器上完成,您需要解析columns[0][search][value]
/ columns[1][search][value]
/ etc并仅将相关行返回给客户端,
您可以使用github尝试使用yadcf和php查找一些相关示例,这里可能是search query on github
p.s你真的应该使用以下语法来初始化yadcf,在构造数据表之后的代码的第一个就绪块中,调用以下代码
yadcf.init(active,.....
答案 1 :(得分:0)
请尝试使用此yadcf
:
yadcf.init(active, [{
column_number: 4,
column_data_type: 'text',
filter_type: 'range_date'
}]);