Search/filter only visible rows

Search/filter only visible rows

skudskud Posts: 3Questions: 1Answers: 0

Hi everyone!

I have a pretty straight-forward grid that has two filter options - a text input to filter all records and a select drop-down that returns records based on the chosen selection. Both are working 100% on their own.

What I'm trying to do is have them work in sync, so that when you filter using the drop-down it returns a set of results, and then I can filter even further within those results using the text input. Basically I want to only filter the visible rows.

At the moment, the text input returns any/all results.

This question has accepted answers - jump to:

Answers

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

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • skudskud Posts: 3Questions: 1Answers: 0

    Hi Colin,

    Thank you for the reply and the info. Below is a test case.

    As per the example, if you use the drop-down or the text input at the top you can filter the table. However, if you filter using one of the options in the drop-down, e.g. System Architect and then want to search e.g. New York, I only want it to return the New York records relating to System Architect whereas it currently returns all New York records.

    http://live.datatables.net/tenixepa/1/edit?html,css,js,console,output

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

    Thanks for the test case, that helped explain it. The solution is to specifically search the role on the first column using column().search(), then search across the entire table with the filter. See here: http://live.datatables.net/tenixepa/3/edit

    Colin

  • skudskud Posts: 3Questions: 1Answers: 0

    Thank you Colin, very much appreciated!

This discussion has been closed.