Disallow searching for specific criteria
Disallow searching for specific criteria
rik1301
Posts: 2Questions: 1Answers: 0
Hello. I have a table with individual search boxes for 2 of my columns (essentially work the same as the integrated column header search boxes). They are set to exact matches only, and the table data is hidden by default.
I have several thousand rows of "?" and "-" in the column where the full info for that particular record is not yet known. Is there a way to prevent people doing a search for "?" or "-" and displaying all these records please?
Answers
There is nothing built into Datatables for this. It will a bit of Javascript coding to handle these characters the way you want. Here are a couple options:
column().search()
.Kevin
OK can you show me an example of how to implement this please. Just for clarity, the search is only executed upon pressing enter or clicking the 'search' button alongside, it is not the standard filter-as-you-type.
Using this example as a base for option 2.
https://live.datatables.net/xejotevo/1/edit
It uses
column().index()
(that.index()
) to specify which column to not allow?
. If its 0 then it also makes sure?
is not in the search string. If there is a?
it clears the input and displays an alert. Otherwise it processes the search normally.Kevin