change filter behaviour on keypress
change filter behaviour on keypress
lara
Posts: 2Questions: 1Answers: 0
Hi,
is it possible to change the behaviour of the dataTable filter on keypress? I would like it to not remove elements from the DOM but instead add a class to the row not matching the filter.
Thanks!
This discussion has been closed.
Answers
The way you'd do something like that is to intercept the keypress using Jquery and write a custom function to do whatever logic you may want (in your case add classes). I'm not sure how you're implementing the filters so I can't really be any more helpful than that.
hi Rpiechura, and thank you for your reply. I am already detecting keypress on the filter input, but it doesn't stop the default behaviour to take place. I don't want to change the default code of dataTables, as I have to do this operation only in one spot. My datatable is configured as follows:
and my jquery function
$(document).on('keyup', ".dataTables_filter input", function() { ... });
And nothing else is being done with filters.
Is this possible without having to modify the dataTables code?
Thank you for your help!
Hmm, I'm used to doing things with server side processing where you can intercept the filter calls entirely since you're making ajax requests for the data. I don't know how you'd do it using client side processing. I wish I could be more help but I'm stumped.
(As such, you may want to mark my response as not an answer so that this goes back to the 'unanswered' portion of the forums.)