How to disable searching in specific DataTable columns?

后端 未结 4 643
面向向阳花
面向向阳花 2021-01-20 16:13

I\'m using successfully this code

function refreshDataTable() {
        // The table is made sortable
        $(\'#order_proposal_table\').DataTable({
              


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-20 16:57

    Remember that the default for 'searching' is true, so to turn on searching for some columns and turn it off for others ou need to do one or the other of these two options:

    1) keep the default setting, and turn off searchable for specific columns:

    "columnDefs": [
        { "searchable": false, "targets": 0,3,5 }
    ]
    

    or 2) turn off the default and then turn it one for specific columns

    "searching": false,
    "columnDefs": [{
        "searchable": true, "targets": 1,2,4,6
    }],
    

    Using "searchabe": true for specific columns will NOT turn off the non-mentioned columns if the default 'searching' is still set to true.

提交回复
热议问题