Callback when filtering is done?

Callback when filtering is done?

mikejmikej Posts: 8Questions: 0Answers: 0
edited December 2009 in General
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.

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Hi mikej,

    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
  • [Deleted User][Deleted User] Posts: 0Questions: 2Answers: 0
    edited November 2011
    I know this thread is very old, but I just had the same issue and worked around it by doing the following:
    [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.
This discussion has been closed.