How can I make the search bar not sync both ways when searching?

How can I make the search bar not sync both ways when searching?

MoghulMoghul Posts: 7Questions: 3Answers: 0

I have two ways to search for things in my datatable - some dropdowns, and a search bar.

They work separately, but when I select a value in a dropdown, and use datatable.api().search(val).draw(), the search bar now ALSO contains the dropdown's selected value.

This effectively means that I can't use both the dropdowns and the search bar together, or that at least the usage would be confusing.

Long story short, I want to make it so that when I use the API search function, the search bar doesn't contain the term i just searched for.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598
    Answer ✓

    Hi @Moghul ,

    Yep, that's the behaviour for that search bar. If you don't want that, you could remove that element from the table (using dom), then insert your own input element (again, using dom) that performs the search but doesn't display it if search is executed through the API.

    Cheers,

    Colin

  • MoghulMoghul Posts: 7Questions: 3Answers: 0

    Thanks for the answer. It would be nice if that was an option in the future.

  • MoghulMoghul Posts: 7Questions: 3Answers: 0

    I mean just being able to make it not update the search bar through some boolean or whatever.

  • allanallan Posts: 63,175Questions: 1Answers: 10,409 Site admin

    The issue there is that search() and the input element use the same thing (i.e. the input actually uses search() under the hood). So not updating it would be confusing when you then go to change its value.

    Its sounds like you might want to implement a search plug-in.

    Allan

This discussion has been closed.