Individual Column (text) Searching - Certain Columns only

Individual Column (text) Searching - Certain Columns only

patricknypatrickny Posts: 14Questions: 6Answers: 0

Is it possible to show the Individual Column (text) searching on certain columns?

When I had it set up as 'select' boxes, there was a line of code that said:
this.api().columns().every which could be changed to this.api().columns([0,1,2,3]).every

This does not seem to be working with the Text search boxes. I am trying to implement these text search boxes in the footer of the table, exactly how they are shown in https://datatables.net/examples/api/multi_filter.html, but I'd like to leave the boxes off of a few columns.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,296Questions: 26Answers: 4,768
    edited May 2020 Answer ✓

    Probably the easiest way is to use a className assigned to the th for each footer you want the search input. Then, from the example you linked to use the className as the selector in line 3 and line 12, like this using my-class:

    Line 3:
    $('#example tfoot th:my-class').each( function () {

    Line 12:
    this.api().columns( '.my-class' ).every( function () {

    Kevin

  • patricknypatrickny Posts: 14Questions: 6Answers: 0
    edited May 2020

    I found more success when I omitted the Line 12 change. When I included the line 12 change, the search would not update the datatable. When I included class='my-class' in the <th> footer tag, and in the line 3 update that you provided, everything works well.

    Thank you for leading me in the right direction (again)!

    http://live.datatables.net/vozejiko/1/

  • kthorngrenkthorngren Posts: 20,296Questions: 26Answers: 4,768

    I found more success when I omitted the Line 12 change.

    Good to know. Glad its working.

    Kevin

This discussion has been closed.