data-search attribute works only if no data-filter attribute

data-search attribute works only if no data-filter attribute

flartflart Posts: 2Questions: 1Answers: 0

Hello, i facing a problem with using a search in combination with custom filter dropdown.
i using a custom render and html 5 attributes like data-sorting data-search and data-filter.

The problem is that the data-search and data-filter has different content and the Datatables used a only a data-filter content for both: filtering and search. If there is no data-filter attribute (removed for testing purpose), than data-search begins working as expected.

It is possible to use those attributes separately?
data-search for the search
and data-filter for the filter

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 17,689Questions: 25Answers: 4,197
    Answer ✓

    This is according to the Orthogonal HTML5 data attributes docs:

    data-filter or data-search - for search data

    Sounds like you can use one or the other but not both. Maybe you can combine both search terms in one attribute. Possibly separated by a space?

    We might be able to offer some suggestions if you can build a simple test case showing an example of the data you have and how you want to search for it.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • flartflart Posts: 2Questions: 1Answers: 0

    Hello Kevin, thank you for the reply. I just found a simple solution.
    I changed the 'data-filter' attribute to 'data-filterS' and change my jQuery code to use that attribute name for the filters, and still use 'data-search' as it was before.

    So now all works as it should. Wish you good day!

  • kthorngrenkthorngren Posts: 17,689Questions: 25Answers: 4,197

    Great, glad you found solution.

    Kevin

Sign In or Register to comment.