How to exclude hidden column from search
How to exclude hidden column from search
leddy
Posts: 16Questions: 5Answers: 1
Hi
I initialise my table like so:
var dtPO = $('#tblPO').DataTable({
"destroy": true,
"info": false,
"lengthChange": true,
dom: 'T<"clear">lfrtip',
tableTools: {
"sRowSelect": "multi",
"aButtons": ["select_all", "select_none"]
}
});
// hide the first column
dtPO.column(0).visible(false);
How do I exclude column(0) from being searchable?
I tried:
$('#tblPO').dataTable({
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [0] }
]
});
but that didn't work
Edit: also tried
dtPO.column(0).search(false); //this stops the whole table being searchable
dtPO.column(0).searchable(false); //gives an error
Thanks in advance
leddy
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Why don't you put your bSearchable and bVisible settings in aoColumnDefs, and put the aoColumnDefs code inside the original DataTables initialisation?
Because I'm an idiot! :) I thought because I was using the API it was different, but I've just tried it and it works great. Thank you
We've all been there.... :-)