Cannot read property 'push' of undefined in datatable

I am trying to implement custom filtering in datatable. But I'm getting this error in console:

Cannot read property 'push' of undefined

I have following code:

$.fn.dataTableExt.afnFiltering.push(
    function( oSettings, aData, iDataIndex ) {
        return true;
    }
);

var table = $('#checkin-checkout-record-table').dataTable({

    "bPaginate": true,
    "bLengthChange": true,
    "bFilter": true,
    "bSort": true,
    "bInfo": true,
    // "order": [[0, 'asc'], [4, 'asc']],
    "aLengthMenu": [50, 100],
    "bAutoWidth": false

});
table.draw();

What is wrong here??

1 answer

  • answered 2017-10-11 10:01 Gyrocode.com

    If you're using newer version (1.10) of jQuery DataTables, you need to use $.fn.dataTable.ext.search.push() instead, see Search plug-ins.

    Also you need to use DataTable() instead of dataTable() to initialize your table if you want to use API by calling table.draw(), see API for more information.