Datatables non-column filtering
Datatables non-column filtering
12hys
Posts: 5Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
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...
[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]