diff --git a/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts b/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts index afd07827d5b5..4f13231027a6 100644 --- a/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts +++ b/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts @@ -1419,13 +1419,15 @@ export const virtualScrollingModule = { loadViewport(params) { const { checkLoadedParamsOnly, checkLoading, viewportIsNotFilled } = params ?? {}; const virtualPaging = isVirtualPaging(this); + if (virtualPaging || gridCoreUtils.isVirtualRowRendering(this)) { this._updateLoadViewportParams(); const loadingItemsStarted = this._loadItems(checkLoading, !viewportIsNotFilled); - + const isCustomLoading = this._dataSource?.isCustomLoading(); + const isLoading = checkLoading && !isCustomLoading && this._isLoading; const needToUpdateItems = !(loadingItemsStarted - || this._isLoading && checkLoading + || isLoading || checkLoadedParamsOnly); if (needToUpdateItems) { diff --git a/testing/testcafe/tests/dataGrid/stateStoring/etalons/T1188828-state-storing-with-selected-row-keys.png b/testing/testcafe/tests/dataGrid/stateStoring/etalons/T1188828-state-storing-with-selected-row-keys.png new file mode 100644 index 000000000000..6303e79fa5a0 Binary files /dev/null and b/testing/testcafe/tests/dataGrid/stateStoring/etalons/T1188828-state-storing-with-selected-row-keys.png differ diff --git a/testing/testcafe/tests/dataGrid/stateStoring/stateStoring.ts b/testing/testcafe/tests/dataGrid/stateStoring/stateStoring.ts index 0f3943ff9417..f4a79c1e42ba 100644 --- a/testing/testcafe/tests/dataGrid/stateStoring/stateStoring.ts +++ b/testing/testcafe/tests/dataGrid/stateStoring/stateStoring.ts @@ -1,7 +1,10 @@ import { ClientFunction } from 'testcafe'; +import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; import url from '../../../helpers/getPageUrl'; import createWidget from '../../../helpers/createWidget'; import DataGrid from '../../../model/dataGrid'; +import { getData } from '../helpers/generateDataSourceData'; +import { makeRowsViewTemplatesAsync } from '../helpers/asyncTemplates'; fixture.disablePageReloads`State Storing` .page(url(__dirname, '../../container.html')); @@ -34,3 +37,46 @@ test('The Grid should load if JSON in localStorage is invalid and stateStoring e }, }); }); + +// T1188828 +test('The rows should render correctly when cellTemplates are used and the selectedRowKeys array contains an invalid key', async (t) => { + // arrange + const dataGrid = new DataGrid(GRID_CONTAINER); + const { takeScreenshot, compareResults } = createScreenshotsComparer(t); + + // assert + await t + .expect(dataGrid.isReady()) + .ok() + .expect(await takeScreenshot('T1188828-state-storing-with-selected-row-keys.png', dataGrid.element)) + .ok() + .expect(compareResults.isValid()) + .ok(compareResults.errorMessages()); +}).before(async () => { + await createWidget('dxDataGrid', { + height: 800, + renderAsync: false, + templatesRenderAsynchronously: true, + dataSource: getData(1000, 1), + columns: [ + { + dataField: 'field_0', + cellTemplate: (_, { value }) => ($('
') as any).text(value), + }, + ], + stateStoring: { + enabled: true, + type: 'custom', + customLoad: () => ({ + selectedRowKeys: ['key-invalid'], + }), + }, + paging: { pageSize: 50 }, + scrolling: { + rowRenderingMode: 'virtual', + }, + }); + + // simulating async rendering in React + await makeRowsViewTemplatesAsync(GRID_CONTAINER); +});