After scrolling down, and updating the datasource, replacing the complete list of items, the grid will show rows with old data. By resizing the (browser) screen the grid re-renders and the correct data is displayed.
π€ Expected Behavior?
It should fully re-render rows after replacing the items in the datasource.
π― Current Behavior
Some rows display old data after replacing all items in the datasource
π Possible Solution
Workaround:
Set grid.dataSource to undefined, wait a tick, and re-set grid.dataSource with the new ArrayDataSource instance.
#createDataSource(users: UserOverviewItem[] = []): void {
if (this.dataSource) {
this.dataSource.removeEventListener('sl-update', this.#onDataSourceUpdate);
this.dataSource = undefined;
}
setTimeout(() => {
// Create new data source
this.dataSource = new ArrayDataSource(users.map(mapUserOverviewItemToUserGridItem));
this.dataSource.addEventListener('sl-update', this.#onDataSourceUpdate);
this.dataSource.update();
}, 0);
}
π₯οΈ Steps to Reproduce
Attach a datasource with lots of items to the grid
Scroll down a few rows (not too far!), e.g. 5 to 10 rows
Now click on a button which will set a new collection of items to the datagrid, a collection of a few items (e.g. 5 items)
The correct number of rows will be displayed, but with the wrong contents
Resize the Browser Window
The grid is updated, now displaying the correct row contents
An error is thrown on the console in the above scenario. This explains why the old data remains on the page. Preventing that error from happening causes the data to update correctly.
Provide a general summary of the issue here
After scrolling down, and updating the datasource, replacing the complete list of items, the grid will show rows with old data. By resizing the (browser) screen the grid re-renders and the correct data is displayed.
π€ Expected Behavior?
It should fully re-render rows after replacing the items in the datasource.
π― Current Behavior
Some rows display old data after replacing all items in the datasource
π Possible Solution
Workaround:
Set
grid.dataSource
toundefined
, wait a tick, and re-setgrid.dataSource
with the newArrayDataSource
instance.π₯οΈ Steps to Reproduce
https://github.com/user-attachments/assets/258ff8cc-d717-4457-8cc1-f20484cc1ef9
What browsers are you seeing the problem on? (only for bugs in code)
Firefox, Microsoft Edge
If other, please specify.
What operating system are you using?
Windows 11
π€ Your name
Jorn Nolles
π§’ Your product/team
Magsiter
π¨ Your Theme(s)
Magister