How can I filter an entire data set, not just the page shown in a table?

How can I filter an entire data set, not just the page shown in a table?

Rob101Rob101 Posts: 1Questions: 1Answers: 0

I have a table that lists emails with an inbox status (inbound, draft, sent) and a true/false flag on is_read.

I want to return a count of all unread messages with an inbound status.

The following works, however it only returns the count for the current page shown (with search values applied). How can I return the total count without updating the table search or pagination itself (I just need the number, I would like the view to remain the same)?

table.on('draw', function() {

    var inboundCount = 0;
    table.rows().data().filter(function(value, index) {
        if (value[1] == 'inbound' && value[3] == 'False'){
            inboundCount++;
            $('#inbound-link-count').html(inboundCount);
        }
    });

}

Answers

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

    I'm surprised that doesn't return all rows across all pages - as you would need {page: 'current'} as selector-modifier for rows() to get the current page.

    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

This discussion has been closed.