how to have 2 counters?
how to have 2 counters?
gibz
Posts: 3Questions: 1Answers: 0
Hello everyone, is there a way to have 2 counters of the selected rows, one per page and another for the total.
Example : "3 rows selected Total : 5 rows selected"
thanks
This discussion has been closed.
Replies
One option is to use
infoCallback
. In the callback you can use the API to get the count of selected rows for both the page and the total. Use theselector-modifier
to limit the rows returned and use thecount()
API to get the count. Here is an example to get the count of selected rows on the page:You may need to disable the
select.info
option.Kevin
Thanks for the answer but I now have 2 other related problems:
1- I don't have the info "Showing 0 to 0 of 0 entries" anymore.
2- the counter for the rows of the pages always mentions 0 selected rows even if a row is selected.
Thanks again!
Here's my code
configDT.infoCallback = function( settings, start, end, max, total, pre ) {
var api = this.api();
var selectedOnPage = api.rows( { selected: true, page:'current' } ).count();
return selectedOnPage + ' rows selected';
}
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