How to use `column().search()` on different columns using different search terms.

How to use `column().search()` on different columns using different search terms.

rdmrdm Posts: 192Questions: 54Answers: 4

I have a scenario where I need to filter column 4 by one term and column 5 by another.

While the first statement works as intended, the second statement never happens. How can I make sure that both searches apply?

detail.column(4).data().search(rowText);
detail.column(5).data().search(colText);
detail.draw();

This question has an accepted answers - jump to answer

Answers

  • rdmrdm Posts: 192Questions: 54Answers: 4

    Could it be this simple? Adding draw to each statement instead of at the end? Although it appears to work as intended, I'm still not sure I'm doing it right.

    detail.column(4).search(rowText).draw();
    detail.column(5).search(colText).draw();
    
  • colincolin Posts: 15,144Questions: 1Answers: 2,586
    Answer ✓

    Hi @rdm ,

    The problem is that you had data() before the search on the first post - your second doesn't.

    Your second post is right, or you could have a single draw(), like this:

      table.column(1).search('Engineer');
      table.column(2).search('San');
      table.draw();
    

    See the example here.

    Cheers,

    Colin

This discussion has been closed.