Skip to content

Commit 36e4297

Browse files
committed
add another test + cover it
1 parent 36a2cce commit 36e4297

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

e2e/testcafe-devextreme/tests/dataGrid/common/pager.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,52 @@ test('Pager info should show page 1 of 1 after changing pageSize to \'all\' with
271271
height: 400,
272272
}));
273273

274+
test('Pager info should show page 1 of 1 after changing pageSize to \'all\' and enabling virtual scrolling (T1327238)', async (t) => {
275+
const dataGrid = new DataGrid('#container');
276+
const pager = dataGrid.getPager();
277+
278+
await t
279+
.expect(pager.getInfoText().textContent)
280+
.eql('Page 5 of 10 (100 items)');
281+
282+
await t
283+
.click(pager.getPageSize(1).element)
284+
.expect(pager.getInfoText().textContent)
285+
.eql('Page 1 of 1 (100 items)');
286+
}).before(async () => createWidget('dxDataGrid', {
287+
dataSource: [...new Array(100).keys()].map((i) => ({ id: i })),
288+
keyExpr: 'id',
289+
showBorders: true,
290+
scrolling: {
291+
mode: 'standard',
292+
},
293+
paging: {
294+
pageSize: 10,
295+
pageIndex: 4,
296+
},
297+
pager: {
298+
visible: true,
299+
allowedPageSizes: [10, 'all'],
300+
showPageSizeSelector: true,
301+
showInfo: true,
302+
showNavigationButtons: true,
303+
},
304+
height: 400,
305+
onOptionChanged(e){
306+
if (e.fullName === "paging.pageSize") {
307+
const setVirtual = e.value === 0;
308+
const targetRenderingMode = setVirtual ? "virtual" : "standard";
309+
const currentRenderingMode = e.component.option("scrolling.mode");
310+
if (currentRenderingMode !== targetRenderingMode) {
311+
e.component.beginUpdate();
312+
e.component.option("scrolling.mode", targetRenderingMode);
313+
e.component.repaint();
314+
e.component.endUpdate();
315+
}
316+
}
317+
},
318+
}));
319+
274320
test('No error should occur if dataSource is not defined and pageIndex is promise chained (T1256070)', async (t) => {
275321
const dataGrid = new DataGrid('#container');
276322

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const changePaging = function (that, optionName, value) {
4343

4444
that._skipProcessingPagingChange = true;
4545
that.option(`paging.${optionName}`, value);
46+
if (optionName === 'pageSize') {
47+
that.option('paging.pageIndex', 0);
48+
}
4649
that._skipProcessingPagingChange = false;
4750
const pageIndex = dataSource.pageIndex();
4851
that._isPaging = optionName === 'pageIndex';

0 commit comments

Comments
 (0)