简体   繁体   中英

date filter type is not working in yadcf plugin

i have column which display date in it. i am using datatable for display tables. i have render date column using datatable's column Render function and use yadcf column filter plugin for filter data. it display datepicker in filter element but not filter data after selecting date from it.

$(table_id).dataTable({
        aaData: $.parseJSON(records), 
"aoColumnDefs": [{
                "bSortable": false,
                "aTargets": [1], // <-- gets last column and turns off sorting
                "mData": null,
                "mRender": function(data, type, full) {
                    var cdate = row.date;
                    return cdate.replace(/(\d{4})-(\d{2})-(\d{2})/, "$3-$2-$1");
}}]
}).yadcf([{column_number: 1, filter_type: "date"}]);

Try the latest yadcf version and also since you are using the - as date sepaartor you need to feed yadcf with the date_format: 'dd-mm-yy'

Updated code:

.yadcf([{column_number: 1, 
         filter_type: "date", 
         date_format:  'dd-mm-yy'
}]);

Here is a working jsfiddle (not sure if you meant to use dd-mm-yy or mm-dd-yy )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM