disallow searching on hidden columns

disallow searching on hidden columns

tonycarreontonycarreon Posts: 6Questions: 1Answers: 0

is there a way to disallow searching on hidden columns?

so i know i can pass bSearchable in the column definitions when the table is created. however, i do not know the columns when the table is created.

i am able to hide the column when after the data is loaded (along with the columns), by calling
var tbl = $("#mytable").DataTable();
for(i=0;i<8;i++){
var c = m.aoColumns[i].sTitle;
if(c != "col1" && c != "col2" ){
tbl.column(i).visible(false);
}

however this still allows the row to show up in searches since the bSearchable is not false.

i am unable to set searchable false in the same way. am i missing something or is there another way i need to do it (after the table is created, not in the constructor)...

Answers

  • tonycarreontonycarreon Posts: 6Questions: 1Answers: 0

    FYI, using data tables 1.10.3

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    There currently is no option to dynamically enable and disable which columns are searchable - sorry.

    Allan

  • tonycarreontonycarreon Posts: 6Questions: 1Answers: 0

    ok, so just so i understand. the only way to set a column as searchable (which is possible) is in the columnDefs when the table is created?

    $("#mytable").dataTable({
    "columnDefs":[ ... ]
    });

    which is not the same as

    $("#mytable").dataTable({
    "columns": [...]
    });

  • tonycarreontonycarreon Posts: 6Questions: 1Answers: 0

    resolved this.

    i just had to step back and re-examine what i was actually doing.

This discussion has been closed.