Get custom filtering active filters

Get custom filtering active filters

vismarkvismark Posts: 79Questions: 5Answers: 0
edited February 2020 in Free community support

I'm using the following method to add custom filtering features:
$.fn.dataTable.ext.search.push(function(oSettings, aData) {});

How can I obtain back which filter value is active on each column?

Also, if I save the table state with stateSaveCallback, those filters won't be saved. This makes me think that applying custom filters this way it's completely different from use this method: table.columns(colId).search(searchString, true, false).draw(true)
But how to use the custom one as if it is the standard one?

Replies

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    See if this thread helps with saving and restoring the columns filters:
    https://datatables.net/forums/discussion/56943

    How can I obtain back which filter value is active on each column?

    You can use column().search() without search parameters to get the search values. Or you can use jQuery to get the input values.

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    Hi @kthorngren

    considering this page (which implements custom filtering) if I use the method you suggested, I only get a blank string. Even if I specify the column, I get a blank string. Try both of this in the console after filtering the age column:
    $('#example').DataTable().column().search()
    $('#example').DataTable().column(3).search()

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Yes, thinking about it using the plugin isn't using the column().search() API to search so it would not show the result. Sorry about that. You will need to interrogate the search inputs directly with jQuery or something else. Datatables has no knowledge or control of these inputs.

    Kevin

This discussion has been closed.