How do I get the names of columns that have a search applied?
How do I get the names of columns that have a search applied?
stevevance
Posts: 58Questions: 6Answers: 1
This is what I've tried so far, but it returns all columns. Only one column has a search applied.
table.columns({"search": "applied"});
Then, if that starts working, how do I get the name of the columns?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
That is really a row selector modifier - it will cause rows which are in the search result to be included.
What to do here is to use
columns().search()
and loop over the resulting array and check to see if it is an empty string or not. If empty, then there is no search applied to that column. You could also usecolumns().every()
and thenthis.search()
inside theevery
callback.Allan
columns().search()
worked to get the indexes of the columns that have a search term applied.Is there a way to get each column's name? I prefer using names because those are more stable identifiers, because I might move columns around and their indexes would change.
Currently no - sorry. There is this ability in the
2
branch of DataTables - but I don't expect that to be finished for several months I'm afraid.Allan