Column Footer Search - search different (hidden) column

Column Footer Search - search different (hidden) column

patricknypatrickny Posts: 14Questions: 6Answers: 0

http://live.datatables.net/xazemoqo/2/edit

I am having difficulty trying to get a Text-Search in the Footer working in a particular way. I have the footer search boxes showing up nicely. If I type a '5' in the 'Grade' column, I get to see all of the 5th graders, immediately.

[note: on the live demo, when you type '5' into grade, the list does not filter. On my version of the table, it does filter.]

However, If I type 'Concert' into the Course column, that behaves differently. In the datatable itself, I dont allow that column to be Searched - because I search a Hidden Column that only shows what course the student is enrolled in.

I'd like the text search box at the bottom of column 2 (courses) .. to search the hidden column 3 (courses-enrolled), if possible.

Thank you for your help.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    edited June 2020 Answer ✓

    First the problem with the grade column search is this error in the browser's console:

    VM850:58 Uncaught TypeError: table.rows(...).deselect is not a function

    You didn't include the select extension so I commented out the last statement in your example.

    You will need to come up with a way to map the search input column to the column you actually want to search. I created a columnSearchMap object that contains a mapping of the search input column to the column it is to search. Using column().index() you can specify the column to search using the mapping variable, for example:
    table.column(columnSearchMap[that.index()])

    Here is the running example:
    http://live.datatables.net/bihenabi/1/edit

    BTW, I made the Course (Enrolled) column visible so I can see the data. You can hide it and it will still work.

    Kevin

  • patricknypatrickny Posts: 14Questions: 6Answers: 0

    Thank you for sharing your superpowers.

This discussion has been closed.