Search where any column contains X and any column contains Y

Search where any column contains X and any column contains Y

nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

Is there a simple way to do an AND search using .search()?

If I do the following I get 10 results:

myDatatable.search("reed med");
myDatatable.draw();

One of which has a field with the value "john".

I was hoping this would work:

myDatatable.search("reed med");
myDatatable.search("john");
myDatatable.draw();

But this appears to search for "reed med" OR "john" as I get 28,000+ results.

Is there a way to search for a match when any column contains X and any column also contains y?

Answers

  • nicontrolsnicontrols Posts: 32Questions: 16Answers: 1
    edited April 2019

    I think it's because my dataTable is serverside. I've looked at the SQL and it seems to only pass across the last .search() value.

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @nicontrols ,

    Yep, as you say, search() will replace any previous search string that was being used - this is the same behaviour whether the table is client side or server side.

    Cheers,

    Colin

This discussion has been closed.