Individual columns search based on the 'Searchable' value of the col
Individual columns search based on the 'Searchable' value of the col
jean
Posts: 12Questions: 5Answers: 0
Looking at https://datatables.net/examples/api/multi_filter.html
What would be the correct way to show those inputs only for col which are actually defined as searchable?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There isn't a public API in DataTables to tell if a column is searchable or not (from the
columns.searchable
flag) - probably an oversight on my part that.However, what you could do is simply add a "searchable" class to searchable columns and then do a
$().hasClass()
check on the element to see if it is searchable or not.Allan
Thanks,
Yes that was the way I was doing it but it still need to change that information in two place (JS definition of the dtable and html) when we change what col are searchable.
It's manageable but would be nice to be able to factorize that and make it automatic.
Thanks for the quick reply!
jean
Agreed! I'll look at providing a plug-in that gives that information.
Allan
Thanks!
Allan - is there any news on this?
Having set up initial params thus (for example):
the most logical thing for adding text search inputs would be (pseudo code):
Maybe it's already possible, but I haven't managed to figure it out.
Basically you need a-priori knowledge of this fact as I've not yet implemented an API method to get this information at run time.
So there are basically two options:
columns.className
and add a class "searchable" to the columns which are searchable. Then use that in your selector.Allan
OK - thanks!