Apply search inputs, but only on some columns
Apply search inputs, but only on some columns
Hello Datatablers,
Into this example we can see how to apply search over all columns:
https://datatables.net/examples/api/multi_filter.html
I am now interested if we have a method to apply only on some of them, but avoiding the conditional approach.
As from the above example this is what I wish to avoid:
$('#example tfoot th').each( function () {
if($(this).index() != 3) //we apply search to all of the columns except the one with index 3,
//I don't wish to put conditions in the code, it's just not practic
{
var title = $('#example thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
}
else
{
//add just an empty td instead of the search box, again not practic
}
} );
Also tried the Searchable property, but no results. The search is still there.
I tried it as here but doesn't work with the example above:
http://datatables.net/reference/option/columns.searchable
Thank you,
Andrei
Answers
So, currently the search display is not dynamic,
here is a more detailed answer
http://www.datatables.net/forums/discussion/22167/is-column-searchability-dynamic
I have searching in every possible combination of tables. Just one or combining them.
This is my footer part:
First column is a jQuery dateslider,
2nd column is a select input,
others are text inputs.
For example;
is the javascript which catches the search.
Do this for every column, check in your backend which search items aren't empty and you know what is searching for.
1 column search will only give one item which is not empty. If more search items are asked for, just add those search items together in a where part for your sql.