Callback when filtering is done?
Callback when filtering is done?
Hi, all.
Just wondering if there is a callback when filtering is done.
I see there are a number of other filters but none for exactly this.
The draw callbacks don't quite do what I need. They are called each time the user does Next>
(which of course doesn't refilter).
I guess I could hack source but would rather not.
Thanks.
Just wondering if there is a callback when filtering is done.
I see there are a number of other filters but none for exactly this.
The draw callbacks don't quite do what I need. They are called each time the user does Next>
(which of course doesn't refilter).
I guess I could hack source but would rather not.
Thanks.
This discussion has been closed.
Replies
There isn't specifically a callback for when filtering is done (providing hooks for this kind of thing are what I want to introduce for the next major release of DataTables (2.x) - but that's probably quite a while off!).
For now what you might consider doing is to unbind the key handler for the input box that DataTables adds for the filter, and then add your own handler. Something like this is done for the fnSetFilteringDelay plug-in ( http://datatables.net/plug-ins/api#fnSetFilteringDelay ). Then you can add your own function/logic in there as well as the call to fnFilter.
Another option would be to use fnDrawCallback and check the settings object to see if aiDisplay has changed length, or perhaps better to see if the search term ( oPreviousSearch.sSearch ) has changed.
Regards,
Allan
[code]
$j('#mimicTable').dataTable({
"oLanguage": {
"sInfoFiltered": 'alert("test")'
}
}).fnSetFilteringDelay(800);
[/code]
Maybe not the cleanest way, but the above code will display an alert box every time a filter takes effect.