Datatables non-column filtering

Datatables non-column filtering

12hys12hys Posts: 5Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
I'm using DataTables with the ColumnFilter plugin with server side processing of the filters, and it works great!

I'm wondering how to add additional filters to DataTables (in the form of selects) that will allow me to do non-column filtering. This would include data that is not shown on the front end, necessarily, but still needs to be filtered on.

Replies

  • 12hys12hys Posts: 5Questions: 0Answers: 0
    I think I might be on to something. I've found the following function: http://www.datatables.net/ref#fnServerParams

    I could add the values of the select filters to this aoData object. Now only to figure out how to trigger DataTables to search after the select is changed...
  • 12hys12hys Posts: 5Questions: 0Answers: 0
    edited June 2013
    Figured it out! Calling fnDraw() with fnServerParams() works perfectly. This is what I was trying to accomplish:

    [code]
    var oTable = $( '#my_table' ).dataTable({
    "fnServerParams" : function( aoData ) {
    var my_select = {
    'name' : 'my_select',
    'value' : $('#my_select').val()
    };

    // adds non-column filter to data that gets sent to the server
    aoData.push( my_select );
    }
    });

    $( '#my_select' ).on( 'change', function(){
    // performs new ajax request
    oTable.fnDraw();
    });
    [/code]
This discussion has been closed.