Trim searchtext in jquery datatables using default searchbox
Trim searchtext in jquery datatables using default searchbox
vijayakumarncse
Posts: 1Questions: 0Answers: 0
I would like the user to do free-text search across all the columns of the data table with server-side property marked as false.Before searching the table how can I trim the search text given by the user?.
I do not want the trim functionality on key-based events as the user would be searching for text with space in between as well.
Ex:
1) 'Micro ' -> 'Micro'
2) 'Micro Soft ' -> 'Micro Soft'
This discussion has been closed.
Replies
You can start with this code and adjust as needed:
It will create a new event handler for the Datatables default global search input. In this case I have regex search on (
true
) and smart search disabled (false
). You will likely want smart search turned off for your requirement. Please see thesearch()
docs for more info regarding regex and smart search.Kevin