-
Notifications
You must be signed in to change notification settings - Fork 668
DataGrid - Pager - Show correct pageIndex when virtualScrolling is enabled on pageSize change #33412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
DataGrid - Pager - Show correct pageIndex when virtualScrolling is enabled on pageSize change #33412
Changes from all commits
664a129
29f7c02
eb5a17d
36a2cce
36e4297
bd3a6da
c1657fa
65b83c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,9 @@ const changePaging = function (that, optionName, value) { | |
|
|
||
| that._skipProcessingPagingChange = true; | ||
| that.option(`paging.${optionName}`, value); | ||
| if (optionName === 'pageSize' && value === 0) { | ||
| that.option('paging.pageIndex', 0); | ||
| } | ||
| that._skipProcessingPagingChange = false; | ||
| const pageIndex = dataSource.pageIndex(); | ||
| that._isPaging = optionName === 'pageIndex'; | ||
|
|
@@ -213,11 +216,7 @@ export class DataController extends DataHelperMixin(modules.Controller) { | |
|
|
||
| this._isPaging = false; | ||
| this._currentOperationTypes = null; | ||
| this._dataChangedHandler = (e) => { | ||
| this._currentOperationTypes = this._dataSource.operationTypes(); | ||
| this._handleDataChanged(e); | ||
| this._currentOperationTypes = null; | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
P.S. this is related to the bug only indirectly. I noticed it while looking for the fix and fixed the bug in several cases |
||
| this._dataChangedHandler = this._handleDataChanged.bind(this); | ||
| this._columnsChangedHandler = this._handleColumnsChanged.bind(this); | ||
| this._loadingChangedHandler = this._handleLoadingChanged.bind(this); | ||
| this._loadErrorHandler = this._handleLoadError.bind(this); | ||
|
|
@@ -588,6 +587,7 @@ export class DataController extends DataHelperMixin(modules.Controller) { | |
| errors.log('W1005', that.component.NAME); | ||
| that._applyFilter(); | ||
| } else { | ||
| this._currentOperationTypes = dataSource.operationTypes(); | ||
| that.updateItems(e, true); | ||
| } | ||
| }).fail(() => { | ||
|
|
@@ -1170,6 +1170,8 @@ export class DataController extends DataHelperMixin(modules.Controller) { | |
| const changeType = change.changeType || 'refresh'; | ||
|
|
||
| change.changeType = changeType; | ||
| change.operationTypes = this._currentOperationTypes; | ||
| this._currentOperationTypes = null; | ||
|
|
||
| if (dataSource) { | ||
| const cachedProcessedItems = this._cachedProcessedItems; | ||
|
|
@@ -1231,36 +1233,32 @@ export class DataController extends DataHelperMixin(modules.Controller) { | |
| } | ||
| } | ||
|
|
||
| public updateItems(change?, isDataChanged?) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code-style changes only |
||
| change = change || {}; | ||
| const that = this; | ||
| change.isFirstRender = !that.changed.fired(); | ||
| public updateItems(change: any = {}, isDataChanged?: boolean) { | ||
| change.isFirstRender = !this.changed.fired(); | ||
|
|
||
| if (that._repaintChangesOnly !== undefined) { | ||
| change.repaintChangesOnly = change.repaintChangesOnly ?? that._repaintChangesOnly; | ||
| change.needUpdateDimensions = change.needUpdateDimensions || that._needUpdateDimensions; | ||
| if (this._repaintChangesOnly !== undefined) { | ||
| change.repaintChangesOnly ??= this._repaintChangesOnly; | ||
| change.needUpdateDimensions ??= this._needUpdateDimensions; | ||
| } else if (change.changes) { | ||
| change.repaintChangesOnly = that.option('repaintChangesOnly'); | ||
| change.repaintChangesOnly = this.option('repaintChangesOnly'); | ||
| } else if (isDataChanged) { | ||
| const operationTypes = that.dataSource().operationTypes(); | ||
| const operationTypes = this.dataSource().operationTypes(); | ||
|
|
||
| change.repaintChangesOnly = operationTypes && !operationTypes.grouping && !operationTypes.filtering && that.option('repaintChangesOnly'); | ||
| change.isDataChanged = true; | ||
| if (operationTypes && (operationTypes.reload || operationTypes.paging || operationTypes.groupExpanding)) { | ||
| change.needUpdateDimensions = true; | ||
| } | ||
| change.repaintChangesOnly = operationTypes && !operationTypes.grouping && !operationTypes.filtering && this.option('repaintChangesOnly'); | ||
| change.needUpdateDimensions = operationTypes && (operationTypes.reload || operationTypes.paging || operationTypes.groupExpanding); | ||
| } | ||
|
|
||
| if (that._updateLockCount && !change.cancel) { | ||
| that._changes.push(change); | ||
| if (this._updateLockCount && !change.cancel) { | ||
| this._changes.push(change); | ||
| return; | ||
| } | ||
|
|
||
| that._updateItemsCore(change); | ||
| this._updateItemsCore(change); | ||
|
|
||
| if (change.cancel) return; | ||
|
|
||
| that._fireChanged(change); | ||
| this._fireChanged(change); | ||
| } | ||
|
|
||
| public loadingOperationTypes() { | ||
|
|
@@ -1273,10 +1271,6 @@ export class DataController extends DataHelperMixin(modules.Controller) { | |
| * @extended: virtual_scrolling, focus | ||
| */ | ||
| protected _fireChanged(change) { | ||
| if (this._currentOperationTypes) { | ||
| change.operationTypes = this._currentOperationTypes; | ||
| this._currentOperationTypes = null; | ||
| } | ||
| deferRender(() => { | ||
| this.changed.fire(change); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1004,18 +1004,19 @@ export const data = (Base: ModuleType<DataController>) => class VirtualScrolling | |
| }; | ||
| } | ||
|
|
||
| private _updateVisiblePageIndex(currentPageIndex?) { | ||
| private _updateVisiblePageIndex(value?: number): void { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just code-style fixes |
||
| if (!this._rowsScrollController) { | ||
| return; | ||
| } | ||
| if (isDefined(currentPageIndex)) { | ||
| this._silentOption(VISIBLE_PAGE_INDEX, currentPageIndex); | ||
|
|
||
| if (isDefined(value)) { | ||
| this._silentOption(VISIBLE_PAGE_INDEX, value); | ||
| this.pageChanged.fire(); | ||
| return; | ||
| } | ||
|
|
||
| const viewPortItemIndex = this._rowsScrollController.getViewportItemIndex(); | ||
| const newPageIndex = Math.floor(viewPortItemIndex / this.pageSize()); | ||
| const viewportItemIndex = this._rowsScrollController.getViewportItemIndex(); | ||
| const newPageIndex = Math.floor(viewportItemIndex / this.pageSize()); | ||
|
|
||
| if (this.pageIndex() !== newPageIndex) { | ||
| this._silentOption(VISIBLE_PAGE_INDEX, newPageIndex); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name of the test suggest that Initial test did it, though: link |
||
| assert.equal(focusedRowChangedFiresCount, 1, 'onFocusedRowChanged fires count'); | ||
|
|
||
| // act | ||
| this.refresh(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the main fix, synchronizes pageIndex between dataSource and dataController when pageSize is changed to 'all' .