Get filter state after setting fnFilter( 'string' ); ?

Get filter state after setting fnFilter( 'string' ); ?

AJRAJR Posts: 1Questions: 0Answers: 0
edited July 2013 in General
Curious if there is an obvious solution to this that I am missing.

I use .fnFilter('string') to set a filter to a table based on a click event to a graph. Setting the filter works just fine. When someone clicks on the same graph element I would like to remove the filter by checking if the new filter string is the same as the last one. In order to know that this is the same element, I need to either store or get the filter state. I checked .fnSettings(), but did not see any attributes relevant to the state of the table's filter. How would one do this?

My ideal solution is:

[code]
var filter_state = oTable.fnGetFilterState()

filter_state = { filter: 'string', column: 0, ... }
[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Currently no - there isn't a method for that - although there will be in 1.10 (the `search()` method will be getter / setter). You could use fnSettings().oPreviousSearch.sSearch ( http://datatables.net/docs/DataTables/1.9.4/DataTable.models.oSettings.oPreviousSearch.html ), but its recommended to not use the settings object as it is not a public API (i.e. setting the search string won't cause a refilter and things like that).

    Allan
This discussion has been closed.