Multiple tables with column search

Multiple tables with column search

NoBullManNoBullMan Posts: 65Questions: 19Answers: 2

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Can I have two different data tables in the same page with column filtering?
I have two tables, both set up exactly the same (of course, with different columns) but only the first one shows the column filtering. The second one just shows cloned header row.

Also, how do you exclude some columns from filtering? I tried specifying column indexes to be excluded and when looping through column in initComplete, I check if index of current column being processed is in that array, skip the process. Doesn't seem to work.

Answers

  • allanallan Posts: 64,010Questions: 1Answers: 10,554 Site admin

    Can I have two different data tables in the same page with column filtering?

    Sure. Perhaps you can post a link to the page you are working on so I cant take a look at see what is happening.

    Also, how do you exclude some columns from filtering?

    It depends how you are setting up the column filtering. If you are using something like this then you would add a suitable selector to the columns() call.

    Allan

  • NoBullManNoBullMan Posts: 65Questions: 19Answers: 2

    Thank you Allen. I will try to create a test page.
    Meanwhile, the link you provided adds the search to footer. I modified it a bit to add it to header and it does work except it replaces the existing header with the one that has text boxes in it. Can one clone the existing header rather than replacing it?
    That is, if I already have an HTML table, with headers defined, can this code be modified to add an extra header row with search boxes in it?

  • allanallan Posts: 64,010Questions: 1Answers: 10,554 Site admin

    Can one clone the existing header rather than replacing it?

    Sure:

    $('#myTable thead tr').clone().appendTo('#myTable thead');
    

    Allan

Sign In or Register to comment.