Hello,
We discovered an issue when attempting to reset a data grid back to the first page when changing the data set. We found that if we called goToPage(1) when changing the dataSource, the grid would go back to the first page of the previous data source, but would not update the data source. If the user was already on page 1, the data source would change as expected.
Please see the StackBlitz here:
https://stackblitz.com/edit/angular-grid-columns-page2plus?file=my-flat-grid.component.ts
Steps to reproduce:
- Click "Data Set 1 (Sales Figures)". Grid loads with sales data.
- Click "Data Set 2 (Names)". Grid loads with name data (completely different data set).
- Using the grid paging function, navigate to page 2.
- Click "Data Set 1 (Sales Figures)". Expected result: grid loads sales data and shows page 1. Actual result: data displayed in the grid is still the name data, although it is now on page 1.
Click "Data Set 1 (Sales Figures)" again. Since the data is on page 1, the data set will change to the sales figures.
Uncheck "Go to page 1 when dataset changes" checkbox. This removes the directive to go to the first page.
Go to page 2 of the sales data.
Click "Data Set 2 (Names)". The data in the grid does change to the name data, although the data is still on page 2.
We are able to work around this issue by wrapping the code that sets the new data in a setTimeout() block. In this case, the call to goToPage() happens first, and then on the new thread the call to change the dataSource does change the data to the correct data set, and will be on page 1, since we changed the page of the old data set back to 1. Because of the workaround, we don't consider this urgent; however, we would still consider this a bug.