How to exclude hidden column from search

How to exclude hidden column from search

leddyleddy Posts: 16Questions: 5Answers: 1
edited May 2015 in Free community support

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

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited May 2015 Answer ✓

    Why don't you put your bSearchable and bVisible settings in aoColumnDefs, and put the aoColumnDefs code inside the original DataTables initialisation?

  • leddyleddy Posts: 16Questions: 5Answers: 1

    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

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Because I'm an idiot! :)

    We've all been there.... :-)

This discussion has been closed.