-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Table: Paginator/Sorting for dynamic data does not work (Bug) #8381
Comments
I don't believe this change is necessary.
// create data source
this.myDataSource = new MatTableDataSource(initialData);
// update data in data source when available
this.streamOfDataUpdates.subscribe(newData => this.myDataSource.data = newData); |
True, that works... I didn't think about that, even though I did a similar thing to fill my data list... ^^ |
How would you subscribe to an array of objects to detect changes? binding mat table to an array and using selectedProcedures is a mat data source object.
|
The data object would still have the same reference. Try this:
|
I tried both above ways even datasource is data is changed, but still we don't find mat-table working and adding the new row |
It might help if you do the following after loading the data.
|
is this work if I go to the next page and further come to the previous page? I don't think it will work. |
|
This works for me like magic. Thanks |
@willshowell i'm stuck with use pagination with BehaviorSubject i was used BehaviorSubject for update table value. Init var:
if you want to update just used
But i face one ISSUE i can't use MatPaginator with BehaviorSubject anyone some idea? |
Not to bad with a bit of massaging
|
@ricardosaracino Thanks so much :) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Currently it is not possible to use the paginator with dynamic data that comes from Subjects (or initially Observables). The paginator seems to work with _data (initialData) set in the MatTableDataSource constructor. You can provide an Array that then transformed into a BehaviorSubject; however passing in a BehaviourSubject directly (e.g. from a service that provides the dynamic data) should be a thing - that would fix the issue described above.
What is the expected behavior?
The table should refresh when switching pages via the paginator.
What is the current behavior?
The table does not refresh when switching pages via the paginator.
What are the steps to reproduce?
Unfortunately I can't provide a functional Plunker because the data I'm using comes from my backend app... But you can find the relevant parts here: http://plnkr.co/edit/exXUHnTlOiEipaH97m4n
Basically you setup a regular MatTable and assign a DataSource. Then you return the BehaviourSubject in your DataSource's connect() method. This makes the data appear in the table - but you won't be able to sort or paginate.
What is the use-case or motivation for changing an existing behavior?
Pagination and sorting should also work with dynamic data. ;)
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material 2
Is there anything else we should know?
It's my third week with Angular. ^^
The text was updated successfully, but these errors were encountered: