How to filter table with greater than or lesser than columns?
How to filter table with greater than or lesser than columns?
Hi,
I'm googling how to filter a datatable with "greater than" or "lesser than" with fnFilter.
And I found this post this http://datatables.net/forums/discussion/537/fnfilter/p1.
Which lead me to http://datatables.net/examples/plug-ins/range_filtering.html, but while reading "$.fn.dataTableExt.afnFiltering.push" code. I don't quite see how to state which table to apply this custom filtering with.
How can I specify which specific tables for the custom filtering?
Thanks!
Best Regards,
Edwin Loh
I'm googling how to filter a datatable with "greater than" or "lesser than" with fnFilter.
And I found this post this http://datatables.net/forums/discussion/537/fnfilter/p1.
Which lead me to http://datatables.net/examples/plug-ins/range_filtering.html, but while reading "$.fn.dataTableExt.afnFiltering.push" code. I don't quite see how to state which table to apply this custom filtering with.
How can I specify which specific tables for the custom filtering?
Thanks!
Best Regards,
Edwin Loh
This discussion has been closed.
Replies
Here an example of multiple tables with several kinds of filters (including from to , I call it filter_type: "range_number")
http://yadcf-showcase.appspot.com/multiple_tables.html
https://github.com/vedmack/yadcf/
Unfortunately this is a limitation of the custom filtering functions. By default they are applied globally.
However, it is actually relatively simple to check for an individual table:
[code]
$.fn.dataTableExt.afnFiltering.push(
function( settings, data, dataIndex ) {
if ( settings.nTable.id !== 'myId' ) {
return true;
}
// filtering logic
}
);
[/code]
Basically, use the `settings.nTable.id` option to limit the search logic to a specific column.
Or checkout Daniel's YADCF plug-in which nicely handles all this stuff internally :-)
Allan
Will the $.fn.dataTableExt.afnFiltering.push method work for server side data too?
I tried to use $.fn.dataTableExt.afnFiltering.push and it works for non server side data.
But when I tried to use it with server side data. It does not work.
Thanks!
Best Regards,
Edwin Loh
No. In server-side processing mode, all the processing is done on the server-side, including filtering. If you want to add more filtering prions when using server-side processing, you need to do it at the server :-).
Allan
Sigh! It "hit" me when I was debugging further after I messaged you. Wasted 2 days!
But, my own sandbox, I got basic filtering using server-side with fnServerParams and calling fnDraw when I want to apply the filter.
Is the the correct way?
Thanks,
Edwin Loh
Allan