$.fn.dataTable.ext.search.push doesn't work

$.fn.dataTable.ext.search.push doesn't work

chrneuchrneu Posts: 3Questions: 1Answers: 0

Hi all,

first of all, thanks for this awesome tool and also for the great support here in the forums. :)

I wanted to try out this tutorial: http://www.datatables.net/examples/plug-ins/range_filtering.html

It's working so far that the datatable is redrawing the table but the client side search doesn't trigger anything.

So right now I'm stuck in this part:

$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#min').val(), 10 );
var max = parseInt( $('#max').val(), 10 );
var age = parseFloat( data[4] ) || 0; // use data for the age column

        if ( ( isNaN( min ) && isNaN( max ) ) ||
             ( isNaN( min ) && age <= max ) ||
             ( min <= age   && isNaN( max ) ) ||
             ( min <= age   && age <= max ) )
        {
            return true;
        }
        return false;
    }
);

Here I am initilizing the datatable:
$(document).ready(function() {
var dt = $('#table').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "classes/readDatabase.php"
}
....

After entering some numbers into the input fields the keyup function as event listener is drawing the table but nothing happens after that.
Could be the data[4] wrong? Or why is it, that the script doesn't jump into $.fn.dataTable.ext.search.push?

Best
Chris

Answers

  • chrneuchrneu Posts: 3Questions: 1Answers: 0

    I just read that it is not possible to do a client search when server side is enabled. Can anyone please provide me a tutorial how to append the age demo to the server side feature? :)

  • jonatascastro12jonatascastro12 Posts: 1Questions: 0Answers: 0

    Hello!

    I have the same issue. Does anyone know sth about it?
    Is this extension working?

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin

    Seems to work okay in the example linked to (does it for you?).

    Can you link to a test page showing the issue so it can be debugged please.

    Are you also using server-side processing? As noted, the filtering needs to be done at the server-side if you are - while that is a client-side plug-in.

    Allan

This discussion has been closed.