Search multi column with different parameters

Search multi column with different parameters

An_AlienAn_Alien Posts: 6Questions: 4Answers: 0
edited May 2019 in Free community support

I'd like to search in 2 different columns. Also, it should be an Or search.

So if the two search parameters are x and y

I want the following rows to be returned:

>  Col A | Col B
>      x    |   y             <Return
>      x    |   a             <Return
>      c    |   y             <Return
>      d    |   i              <Don't return

I know that we have columns().search which accepts an array for multi column but how can I search for multiple parameters

This question has an accepted answers - jump to answer

Answers

  • An_AlienAn_Alien Posts: 6Questions: 4Answers: 0
    edited May 2019

    I was thinking of using regex like this:

    this._datatable.columns([9, 11])
          .search("Manual|Pending", true, false)
          .draw();
    

    But that returns nothing

  • colincolin Posts: 15,146Questions: 1Answers: 2,586
    Answer ✓

    Hi @An_Alien ,

    It won't work across columns, as the columns are ANDed, not ORed, but if those values are unique to those columns, you could do a full table search(), something like this. That's explained more in this thread.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.