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?

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);
}
});
}
This discussion has been closed.
Answers
I'm surprised that doesn't return all rows across all pages - as you would need
{page: 'current'}
asselector-modifier
forrows()
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