Setting input value of search field (per column)
Setting input value of search field (per column)
Apologies if this is simple, but I've been stuck on this for some time and it's making my head hurt. I have a need to persist the search values of columns between tabs and screens. This is working when tabs are changed, but when the user changes screens and returns, the search field value (per column of data table) are lost, although the search value is reloaded. This is expected, as I know it's not built in to persist save values between screens. I have a function built that queries the data tables persistence for a column to get the value being loaded, however I just can't work out the jquery required to actually set the value. I have the index of the column and the value that should be there in the search input field, but I'm just not able to work out the jquery to set the value.
Please, if someone is able to tell me how to set the search field with a value using a given index using jquery it'd be very much appreciated.
Answers
jQuery().val()
to set the value of aninput
element.I'd need to see some code, or even better a live example on StackBltiz or similar to be able to offer much more help than that.
Allan
Sounds like you have
stateSave
enabled and want to restore the search inputs withcolumn().search()
values. There are lots of threads asking this. Maybe one of the solutions in this thread will help. If you still need help please post a link to the test case Allan asked for so we can offer more specific suggestions.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin