I am trying to use global filtering on a datatable with an AJAX source as follows:
var usertable = $("#userstable").dataTable({ "bProcessing": false, "bJQueryUI": false, "bAutoWidth": false, "bServerSide": true, "aLengthMenu": [[10, 30, 50, 100], [10, 30, 50, 100]], "iDisplayLength": 30, "sDom": '<"H"fl>t<"F"ip>', "sAjaxSource": "fetchmyusers.php", "sPaginationType": "full_numbers", "fnDrawCallback": function( oSettings ) { console.log('fnDrawCallback called'); } });
datatable compatible works with default sort / filter options. Now I want to display only those users who are registered in a certain period of time. To do this, I take input from the user for the start and end dates and by clicking the binding, I want to filter users according to this date.
jquery code for it:
$("#customdatefilter").on('click',function(e) { e.preventDefault(); usertable.fnDraw();
Then I need to write a custom filter function as follows:
$.fn.dataTableExt.afnFiltering.push( function( oSettings, aData, iDataIndex ) { console.log('filtering..');
But the problem here is that this custom filter is never called. But the redraw data callback was successful.
1) Does this type of custom filtering work with AJAX source data?
2) Are any of my initialization options missing / incorrect?
I found a similar request on the site , but it didnβt help me.