How to display filtered data after filter(FUNCTION) has been applied

How to display filtered data after filter(FUNCTION) has been applied

vcicmanecvcicmanec Posts: 6Questions: 2Answers: 0

Is there a way to display the data, for which the result of function in the filter() call returns true?

What I mean is, I call

table.columns( [0, 1] ).data().filter(my_custom_function)

If I add .draw() after this, the table is not affected.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    The filter() function filters the result set, not the table. The search() method is used for the search option.

    As the documentation for filter() says:

    The filter() method provides a way of filtering out content in an API instance's result set which does not pass the criteria set by the provided callback method. This method should not be confused with search() which is used to search for records in the DataTable.

    Not the answer you want I know - but that is why it isn't doing as you expect.

    Having the ability to give a function to search() is a feature I'm planning to add in future.

    Allan

This discussion has been closed.