dynamically set which columns are searchable after a dataTable has been initialized
dynamically set which columns are searchable after a dataTable has been initialized
lsiden
Posts: 2Questions: 2Answers: 0
Hi, I found a reply to my question here, http://datatables.net/forums/discussion/9665/dynamically-changing-filter-column-bsearchable, but it applied to version 1.9.3 and I'm on 1.10.1 now and it no longer works.
Is there still a way to dynamically set which columns are searchable after a dataTable has been initialized?
This discussion has been closed.
Answers
I was looking for the solution to this situation as well. It would be nice to have a column().searchable() which behaves like 1.10's column().visible() function, but short of submitting a pull request (which I might do when I get some time), the following worked for me:
I think these would be more "correct" if they operated chained to a column() call instead of taking a name parameter, but I wanted to hide the whole name + ":name" manipulation.
Note that these rely on columns having a name value and assume a single table (the [0] index).
I should point out that this is using a private API and therefore not directly supported. However I don't see any reason why it wouldn't work.
This is something that will be included in the core API in future as it has been asked for a few times recently.
Allan