Modify search bar to only search on one column
Modify search bar to only search on one column
Possible solutions and why they aren't adequate:
1. Creating my own custom search bar, calling the Datatables api, and then hiding the default search bar that comes with Datatables. It just seems like a lot of unnecessary work as I want to maintain the positioning and styling of the default search bar and just want to change the functionality.
2. Setting "searchable": false for all the columns except the one I want. I have some other custom buttons that do need to be able to filter on other columns, which is why I specifically need to change the search bar functionality to only work for one column.
All I want to be able to do is make is so the default search bar only searches on one column. Any help is appreciated!
This question has an accepted answers - jump to answer
Answers
One option is to take over the global search input's
keyup
event and in the event handler usecolumn().search()
, like this example:http://live.datatables.net/kiwoxuma/24/edit
Another option is to create your own input as you described. You can use the technique in this custom toolbar elements example to add input with the other Datatables elements.
Kevin