How to customize "Selected # rows" when using server-side processing?
How to customize "Selected # rows" when using server-side processing?

I was able to customize the text itself with the following configuration:
language: {
select: {
rows: {
_: "Selected %d rows",
0: "Click a row to select it"
}
}
}
However, the previous selected rows are removed from the DOM when using serverside processing in DataTables. I am currently storing the ids of the selected rows in an array called "selectedRows". I want to use the length of that array in place of "%d" but the table always see the value of the array as 0.
How do I override this label to always show the correct row count in server-side processing?
This discussion has been closed.
Answers
Hi @steven408 ,
The easiest way would be to just over-write the existing string in
drawCallback
with what you want - something like this.Cheers,
Colin
Hi Colin,
I would like to retain the first part of the dataInfo though "Showing 26 to 41 of 89 entries Selected 5 rows". I would only like to override the 2nd part of the string "Selected 5 rows" to use my array count (stores the correct number of rows).
Yep, so you can read that initial string, then modify it to suit your purposes, like this.
In server-side scrolling, overriding the text in the drawCallback section changes the text for a short time. Once it exits out of the drawCallback section, the text reverts back to the previous text "Showing 26 to 41 of 89 entries Selected 5 rows" rather than "Showing 26 to 41 of 89 entries and fred".
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