Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatTableDataSource with Pagination does not update with data change less than paginator's index #14010

Closed
ryboucher opened this issue Nov 6, 2018 · 1 comment · Fixed by #14665
Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@ryboucher
Copy link

Bug, feature request, or proposal:

Bug

What is the expected behavior?

If you change the MatTableDataSource's data to a smaller set and the paginator is on a page further than the new data's length, the data should be shown with the updated paginator.

What is the current behavior?

When you change the datasource's data to a smaller set than the paginator's index, the index updates but the data is not shown until the you change the paginator to a different page size.

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: https://goo.gl/wwnhMV

https://stackblitz.com/edit/angular-chekxx

  1. Go to the 2nd or 3rd page of the data
  2. Press the switch data button (Array of 1 instead of 20 will load)
  3. Observe the paginator has updated but data is not displaying

What is the use-case or motivation for changing an existing behavior?

To be able to use the default datasource when the data it is using may change.

Is there anything else we should know?

Looking at the source code, it seems the data source's _updatePaginator function is wrapped with a promise. This seems to cause the paginator's index to update after the _pageData function already resolves, making the paginator update while the _pageData function uses the old index to filter the data.

image

@vivian-hu-zz vivian-hu-zz added the P2 The issue is important to a large percentage of users, with a workaround label Nov 8, 2018
@crisbeto crisbeto self-assigned this Dec 28, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 28, 2018
…than the current page

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on angular#12586).

Fixes angular#14010.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 28, 2018
…than the current page

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on angular#12586).

Fixes angular#14010.
vivian-hu-zz pushed a commit that referenced this issue Jan 16, 2019
…than the current page (#14665)

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on #12586).

Fixes #14010.
s2-abdo pushed a commit to s2-abdo/material2 that referenced this issue Jan 18, 2019
…than the current page (angular#14665)

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on angular#12586).

Fixes angular#14010.
s2-abdo pushed a commit to s2-abdo/material2 that referenced this issue Jan 18, 2019
…than the current page (angular#14665)

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on angular#12586).

Fixes angular#14010.
vivian-hu-zz pushed a commit that referenced this issue Jan 18, 2019
…than the current page (#14665)

Fixes the table not rendering correctly when going from a large set of data (e.g. 50 items and on page 10) to a small set of items (e.g. 1 item). The issue comes from the fact that the paginator doesn't emit events if they weren't generated by the user (see discussion on #12586).

Fixes #14010.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
4 participants