Test if a column is searchable
Test if a column is searchable
yshtil
Posts: 17Questions: 6Answers: 0
Here is a code fragment that changes the footer of each column into an input type search. How do I test if the relevant column is searchable and do not do it if not searchable?
$('#usersData tfoot th').each(function () {
var title = $(this).text();
$(this).html('<input type="search" placeholder="Search ' + title + '" />');
});
The "usersData" tag is that of the relevant table.
This question has an accepted answers - jump to answer
Answers
There isn't an API method to determine if a column is searchable, so you'll need to remember what the original config is. each() has an index parameter that you can check against, and just return from the function is it's one that's not searchable.
Colin
You aren't the first to ask about this, so I've created a little plug-in that adds an API method for this.
You can see an example here.
Allan
Your plugin is written in Java, am I missing something? My understanding is that Java is a no-no on the client side.
The link in the repo is written in Typescript. The code at the bottom, which is also used in the example, is written in Javascript. There is no Java in any of the code.
Kevin