Columns Individual Search

Columns Individual Search

svrpsvrp Posts: 4Questions: 1Answers: 0
edited May 20 in DataTables


I'm trying to make a column search for individual columns

And I have this code that is called on a document ready function from jquery.

However, when I start searching on one of these fields, my table disappears. Any help on this?

Thank you.

This question has an accepted answers - jump to answer


  • allanallan Posts: 54,181Questions: 1Answers: 8,456 Site admin

    You can't add a footer after DataTables has been initialised. What you'll need to do is add the header first (or put it in the HTML) - then clone that, insert the input elements and then finally initialise the DataTable.


  • svrpsvrp Posts: 4Questions: 1Answers: 0
    edited May 20

    Hi Allan,

    Thank you for your reply.

    I already tried that and I put the inicialization of headers on HTML, however, as you can see here:
    The same happens, even without that clone. The table disappears when I start writing on the search inputs.

  • svrpsvrp Posts: 4Questions: 1Answers: 0

    One more example,
    I tried to modify I bit.

    I delete some scroll functions and now the table does not disappear but It does not make the search properly (it does not appear the row that I search).

    I'm doing anything wrong?

    the colIdx gives me the correct value and also the this.value of my search.

  • colincolin Posts: 12,109Questions: 0Answers: 2,059
    Answer ✓

    As you can see in your debug, your searching on both columns - your code becomes

                      .columns( [0, 1] )
                      .search( this.value )

    DataTables searches are ANDs - so as it's looking for the same string in both columns, nothing is matched. You need to search on the one column where the input element is.

    This example is doing what you want to do:


  • svrpsvrp Posts: 4Questions: 1Answers: 0

    Yes it was that the problem.

    I made an example with the solution, so I can help any other with the same problem:

    The working solution is on the link above. Thanks.

Sign In or Register to comment.