Outside checkboxes to filter rows

Outside checkboxes to filter rows

diegolazdiegolaz Posts: 3Questions: 1Answers: 0

Description of problem: So I added 4 checkboxes outside the table, and when selecting I show/hide rows with specific info. But for example from a 50 results table if I filter that way and get say 5rows, it still shows as it has 50 on the counter... is there a way to do manual filtering with for that purpose?

Thanks!

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    Answer ✓

    See if this example helps:
    https://live.datatables.net/vipifute/1/edit

    Kevin

  • diegolazdiegolaz Posts: 3Questions: 1Answers: 0

    Thank you both! Was about to right a test case example but see the answer is exactly what I was looking for.
    Thanks!

  • diegolazdiegolaz Posts: 3Questions: 1Answers: 0

    Hello! Sorry I have a follow up on this question.
    I'm currently doing a search (based on the checkboxes) on a column like the example previously provided... I see the | on the saerch string is an OR command...
    like "searchparam1|searchparam2|searchparam3" ....
    var statusFilter = "searchparam1|searchparam2|searchparam3";
    myTable.column(4).search(statusFilter, true, false, false).draw(false);

    but for one case, I need to do a search on another column.... I can you handle that?
    It would be
    myTable.column(4).search(statusFilter, true, false, false).draw(false);
    and
    myTable.column(5).search("0", true, false, false).draw(false); only if in sattusFilter it contains "searchParam1" ...

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    Answer ✓

    Yes you can apply column().search() to multiple columns. It will be treated as a and search so both conditions need to be true to display the row. For example:

    myTable.column(4).search(statusFilter, true, false, false).draw();
    
    if ( condition ) {
      myTable.column(5).search("0", true, false, false).draw();
    }
    

    You probably won't want to pass false as a parameter to api draw().

    If you want an OR search use a Search Plugin.

    Kevin

Sign In or Register to comment.