How to disable filtering on specific columns

How to disable filtering on specific columns

xyuukixyuuki Posts: 2Questions: 1Answers: 0

I want to disable filter on the first and last columns but I am not sure how to do it as I'm new to DataTables.

Answers

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    columns.searchable is used to remove columns from searching.

    Kevin

  • xyuukixyuuki Posts: 2Questions: 1Answers: 0

    Do you have any example for my case? I can't really understand the Documentation

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    You can use columnDefs and set the columnDefs.targets as your column indexes. They start at 0 so the first column is 0. Looks like you have 6 columns, numbered 0-5. You would add to your Datatables initialization config something like this:

      "columnDefs": [
        { "searchable": false, "targets": [0, 5] }  // Disable search on first and last columns
      ]
    

    Kevin

This discussion has been closed.