Skip to content

Commit

Permalink
DataGrid - Reinitialize viewportParams and pageLoadSize on filter app…
Browse files Browse the repository at this point in the history
…lication (T1118229) (#24226)

Co-authored-by: evgenii.ovchinnikov <[email protected]>
  • Loading branch information
Alyar666 and yuyugene authored Apr 12, 2023
1 parent 4364a2b commit f2a8476
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/ui/grid_core/ui.grid_core.virtual_scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,10 @@ export const virtualScrollingModule = {
this._itemCount = 0;
this._allItems = null;
this.callBase.apply(this, arguments);
},
_applyFilter: function() {
this._dataSource?.loadPageCount(1);
this.callBase.apply(this, arguments);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import $ from 'jquery';
import pointerMock from '../../helpers/pointerMock.js';
import translator from 'animation/translator';
import dataUtils from 'core/element_data';
import ODataStore from 'data/odata/store';


const dataGridWrapper = new DataGridWrapper('#dataGrid');
Expand Down Expand Up @@ -7443,6 +7444,63 @@ QUnit.module('Infinite Scrolling', baseModuleConfig, () => {
assert.equal(spyLoad.args[spyLoad.callCount - 1][0].take, 20, 'take is not changed after scrolling up');
});

QUnit.test('There should be no extraneous data being requested when searching or resetting search via searchPanel(T1118229)', function(assert) {
// arrange
const getData = function() {
const items = [];
for(let i = 0; i < 30; i++) {
items.push({
id: i + 1,
name: `Name ${i + 1}`,
rating: i % 3
});
}
return items;
};

const store = new ODataStore({
key: 'id',
url: 'test',
data: getData(),
filter: ['rating', '>', 1],
});

store.load = sinon.spy(function(parameters) {
return $.Deferred().resolve(getData().slice(parameters.skip, parameters.take));
});

const dataGrid = createDataGrid({
height: 300,
showBorders: true,
searchPanel: { visible: true },
paging: {
pageSize: 10
},
dataSource: store,
remoteOperations: true,
pager: { visible: true },
scrolling: { mode: 'infinite' },
});
// act
this.clock.tick(300);

dataGrid.getScrollable().scrollTo({ top: 4000 });
this.clock.tick(300);

dataGrid.option('searchPanel.text', '12345');
this.clock.tick();

// assert
assert.equal(store.load.lastCall.args[0].take, 10, 'only a single page is requested');

// act
dataGrid.option('searchPanel.text', '');
this.clock.tick();

// assert
assert.equal(store.load.lastCall.args[0].take, 10, 'only a single page is requested');
});

QUnit.test('Refresh call should not reset scroll position during scrolling (T1076187)', function(assert) {
// arrange
const getData = function(count) {
Expand Down

0 comments on commit f2a8476

Please sign in to comment.