Search on hidden columns not working
Search on hidden columns not working
Hi
When using the responsive plugin searching on hidden columns seems not to work.
The column is hidden fine, but also not searchable
Since I am using JQUERY mobile I have this code run when a tab becomes visible:
$("#tabs").tabs({ activate: function(event, ui){
//console.log(event);
//alert(ui.newTab.index());
switch(ui.newTab.index()) {
case 1:
var oTable = $('#installs').DataTable({retrieve: true});
oTable.column(8).visible(false,true).draw(false); // Hide the column with location names
oTable.columns.adjust().responsive.recalc();
break;
case 5:
var oTable = $("#docs").DataTable({retrieve: true});
oTable.columns.adjust().responsive.recalc();
break;
}
}});
It is the table #installs that has the problem - Column 8 (or nine when counting from one) is the column that should be searchable but hidden, but it appears that the column is completely removed from the DOM making it of course not searchable... ???
Does anybody have any ideas ?
Thanks !
/Henrik
Replies
Are you searching using the built in search field or your own custom searching function?
The built in search field will work and search those hidden fields. I have a DataTable that I am also the row grouping functionality https://datatables.net/examples/advanced_init/row_grouping.html, and hiding the column being used to group by.
Even in the example provided in the link, you can search for "London" and all associated rows are shown.
I am using the built in search field but it does not work when searching for a value in the hidden column but it does work when searching a value matched by some other field.
I am not using row grouping - Column 8 is simply to be hidden but still searchable - but the problem appears to be that the <th> and <td>s that consitute the column are removed completely from the DOM and then of course the column cannot match any search filter, since it does no longer exist in the DOM ?
Well want I actually want is for the built-in search field to work normally for all columns except for column 8 since in this column I have a comma separated list of names like (firstname1 surname1, firstname2, surname2)
So I want to disable smart search for column 8 (I think) ? How can I do that ?
https://datatables.net/reference/option/columns.searchable
Add that to your columnDef for column 8.
ok thx