Inconsistency between info display and table.rows({selected: true}).count() in DataTables 2.x with r

Inconsistency between info display and table.rows({selected: true}).count() in DataTables 2.x with r

pdw1031pdw1031 Posts: 1Questions: 1Answers: 0

Subject: Inconsistency between info display and table.rows({selected: true}).count() in DataTables 2.x with rowId and state persistence

Description:

I am experiencing an inconsistency in the selection count display when using DataTables 2.3.2 with the Select extension, rowId, and state persistence (which is the default behavior in 2.x).

Steps to Reproduce:

Initialize a DataTable with:
rowId set to a unique field (e.g., 'id').
select: { style: 'single' } (or 'multi').
Standard configuration (no custom infoCallback).
Navigate to Page 1 and select a row.
Navigate to Page 2 and select a different row.
Observe the info element at the bottom of the table.
Expected Behavior (based on DataTables 1.11):

The info element should show 1 row selected (or X entries... 1 row selected).
The JavaScript call table.rows({selected: true}).count() returns 1.
The counts should be consistent.
Actual Behavior (in DataTables 2.3.2):

The info element incorrectly displays 2 rows selected.
However, the JavaScript call table.rows({selected: true}).count() correctly returns 1.
This creates a contradiction: the UI shows 2 selected, but the API reports only 1.
Additional Context:

This behavior is linked to the enhanced state persistence in 2.x. The info component seems to be counting the persistent selection state (including the row from Page 1 that was deselected when the Page 2 row was selected) differently than the table.rows({selected: true}) API method.
The table.rows({selected: true}) method correctly reflects the current single selection state (count = 1), but the built-in info display from the Select extension appears to show an incorrect total.
This issue does not occur in DataTables 1.11, where the selection state was not persisted across pages/filters in the same way.
Impact:
This inconsistency is confusing for users and developers, as the UI display contradicts the programmatic query result.

Request:
Please investigate if this is a bug in the Select extension's info display logic when state persistence is active. The count shown in the info element should be consistent with the result of table.rows({selected: true}).count().

Thank you for your attention to this matter.

Answers

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    Could you link to a test case showing the issue please? I've tried to recreate it here but it seems to be working as expected.

    Thanks,
    Allan

Sign In or Register to comment.