Skip to content

DataGrid - Pager - Show correct pageIndex when virtualScrolling is enabled on pageSize change#33412

Merged
Tucchhaa merged 15 commits into
DevExpress:26_1from
Tucchhaa:fix_grid_pager_26_1
Jun 4, 2026
Merged

DataGrid - Pager - Show correct pageIndex when virtualScrolling is enabled on pageSize change#33412
Tucchhaa merged 15 commits into
DevExpress:26_1from
Tucchhaa:fix_grid_pager_26_1

Conversation

@Tucchhaa

Copy link
Copy Markdown
Contributor

No description provided.

@Tucchhaa Tucchhaa force-pushed the fix_grid_pager_26_1 branch from 0b6a17d to 664a129 Compare April 27, 2026 10:05
@Tucchhaa Tucchhaa marked this pull request as ready for review April 28, 2026 10:37
Copilot AI review requested due to automatic review settings April 28, 2026 10:37
@Tucchhaa Tucchhaa requested a review from a team as a code owner April 28, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes DataGrid pager’s displayed page index when switching the page size to “all” (internally pageSize = 0) while virtual scrolling is enabled, ensuring the pager info shows a valid “Page 1 of 1 …” state.

Changes:

  • Adjust pager page index calculation to handle pageSize === 0 (the “all items” mode).
  • Add a TestCafe e2e regression test covering the virtual-scrolling + pageSize “all” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/devextreme/js/__internal/grids/grid_core/pager/m_pager.ts Ensures pager’s 1-based pageIndex is correct when pageSize is set to 0 (“all”).
e2e/testcafe-devextreme/tests/dataGrid/common/pager.ts Adds regression test verifying pager info becomes “Page 1 of 1 …” after switching to “all” with virtual scrolling.

Comment thread packages/devextreme/js/__internal/grids/grid_core/pager/m_pager.ts
export const MAX_PAGES_COUNT = 10;

const getPageIndex = function (dataController) {
if (dataController.pageSize() === 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lines may confuse later, I think it should be fixed on pageIndex level instead
like changePaging in data controller resets pageIndex to 0 in case of pageSize = 0, same should be here, also you may notice that after changing to pageSize = All grid shows 1st page (rows from 1), not keeps the prev one

@Tucchhaa Tucchhaa force-pushed the fix_grid_pager_26_1 branch from f4a744f to 09c0b62 Compare May 6, 2026 10:25
Copilot AI review requested due to automatic review settings May 6, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings May 8, 2026 05:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings May 8, 2026 06:41
@@ -671,7 +671,7 @@ QUnit.module('Real DataController and ColumnsController', {
this.cellValue(0, 2, '5');
this.saveEditData();
// assert
assert.equal(focusedRowChangedFiresCount, 2, 'onFocusedRowChanged fires count');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of the test suggest that focusedRowChangedFiresCount should increase after refresh, but current test doesn't check it.

Initial test did it, though: link

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings May 8, 2026 07:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread e2e/testcafe-devextreme/tests/dataGrid/common/pager.ts Outdated
Copilot AI review requested due to automatic review settings May 20, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/devextreme/js/__internal/grids/grid_core/data_controller/m_data_controller.ts:57

  • When setting pageIndex/pageSize, changePaging now returns an already-resolved Deferred instead of returning the dataSource.load()/reload() Deferred. This breaks the existing contract where callers can chain .done(items => ...) and receive the loaded items after paging completes (see existing tests like testing/tests/DevExpress.ui.widgets.dataGrid/dataController.tests.js that assert the loaded items in the .done callback). Please restore returning the actual load/reload promise (and its resolved items) while still fixing the pageIndex reset behavior for pageSize changes.
      return Deferred().resolve().promise();
    }
    return dataSource[optionName]();
  }

Copilot AI review requested due to automatic review settings May 22, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread e2e/testcafe-devextreme/tests/dataGrid/common/pager.ts
Comment thread e2e/testcafe-devextreme/tests/dataGrid/common/pager.ts
Copilot AI review requested due to automatic review settings May 22, 2026 11:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Comment on lines +314 to +326
onOptionChanged: (e) => {
if (e.fullName === 'paging.pageSize') {
const setVirtual = e.value === 0;
const targetRenderingMode = setVirtual ? 'virtual' : 'standard';
const currentRenderingMode = e.component.option('scrolling.mode');
if (currentRenderingMode !== targetRenderingMode) {
e.component.beginUpdate();
e.component.option('scrolling.mode', targetRenderingMode);
e.component.repaint();
e.component.endUpdate();
}
}
},
@Tucchhaa Tucchhaa force-pushed the fix_grid_pager_26_1 branch from 15682ba to 07a49c2 Compare May 22, 2026 11:59
change.needUpdateDimensions = change.needUpdateDimensions || that._needUpdateDimensions;
if (this._repaintChangesOnly !== undefined) {
change.repaintChangesOnly ??= this._repaintChangesOnly;
change.needUpdateDimensions ??= this._needUpdateDimensions;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same as previous version, now we override undefined only, before we also update value for false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

change.needUpdateDimensions = true;
}
change.repaintChangesOnly = operationTypes && !operationTypes.grouping && !operationTypes.filtering && this.option('repaintChangesOnly');
change.needUpdateDimensions = operationTypes && (operationTypes.reload || operationTypes.paging || operationTypes.groupExpanding);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep prev version, it was easier for reading, also we changes logic a bit: now it unconditionally assigns true/false/undefined whereas before it left a pre-existing value alone when the condition was false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

that._skipProcessingPagingChange = true;

if (optionName === 'pageSize') {
that.option('paging.pageIndex', 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to update paging.pageIndex not in the same moment as dataSource.pageIndex? If not, let's combine them in single condition for readability

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combined, but had to update one qunit test:

Because it checked that pageIndex should be 0, but since we decided to keep the pageIndex between finite pageSize changes, the test is not actual anymore


that._skipProcessingPagingChange = true;

if (optionName === 'pageSize') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add here condition: && value === 0 to reset page index only for 'All' case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

Copilot AI review requested due to automatic review settings June 3, 2026 06:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

anna-shakhova
anna-shakhova previously approved these changes Jun 3, 2026
Copilot AI review requested due to automatic review settings June 3, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@Tucchhaa Tucchhaa merged commit 851f460 into DevExpress:26_1 Jun 4, 2026
107 of 108 checks passed
@Tucchhaa Tucchhaa deleted the fix_grid_pager_26_1 branch June 4, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants