-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Add detailed documentation for using DataSource with MatTable #8227
Comments
+100 To add to this, I've gotten everything to work except for updating the datatable's dataSource with new data from a service. This is mostly an RxJS, Observable related question. A real-world use case for this would be a search input where users can search and endpoint, return an array of results, and refresh the datatable - in 2 days I can't figure out how to make this work. datatable.component.ts
search.service.ts
|
Working on this now at #8162 - please feel free to add comments to help contribute |
@iamwhitebox: I spent a few days to get this working too. For my service, I used the following approach to make clients aware of updates: I used the following example for the table setup: On that notification back in my component, when data is received, I set the passed in array of data to a local instance (which is used to replace the NAMES and COLORS variables from the stackblitz example). |
I had lot of troubles trying to use this approach: import { DataSource } from '@angular/cdk/collections'; I could get the table, but to sort the columns was impossible because sort wasn't a known property of Datasource, etc, etc finally i noted that was using "@angular/material": "^5.0.0-rc0", Currently I'm working with MatTableDataSource IMPORTS import {MatTableDataSource} from '@angular/material'; CLASS VARIABLES private ELEMENT_DATA: reportInterface[] = []; and in the constructor this.dataService.getReport().subscribe(results => { and here is my filter function applyFilter(filterValue: string) { I think this is faster and easier |
It would have helped me a lot to give the transition steps from a REST data source populating a plain HTML table to a mat-data. Like whitebox (above), i've spent a few hours on this already and haven't found joy |
Another PR to improve docs as well as open up the table data source API to allow just normal data arrays and streams that emit arrays. If changes to your data occurs, you have the option to call |
Agreed, I think allowing normal arrays to be the datasource would simplify
things for a lot of users.
…On Tue, Jan 23, 2018 at 6:51 PM, Andrew Seguin ***@***.***> wrote:
Another PR to improve docs as well as open up the table data source API to
allow just normal data arrays and streams that emit arrays. If changes to
your data occurs, you have the option to call renderRows rather than
changing your data array reference.
#9489 <#9489>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#8227 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFrq6iOp7Tpxw7zGQ9xoFIYTgPfh17pdks5tNnCbgaJpZM4QRwuL>
.
|
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. |
Proposal: Add detailed documentation for using DataSource with Material Table. Current documentation on DataSource is very high level. Tutorial level documentation, starting with basic table, then adding sort and paging would be good.
What is the expected behavior?
Level of documentation to make using Mat-Table and DataSources, along with Observables more developer friendly.
What is the current behavior?
Very minimal level of documentation regarding how DataSources work with Mat-Table, pagination, and observables.
What are the steps to reproduce?
Have an AngularJS developer add a Mat-Table to a seed project, and use DataSource, Observable, http.get(), and pagination/sorting on the table. Documentation seems lacking to do this. A tutorial would be great.
What is the use-case or motivation for changing an existing behavior?
Make Angular (4) more accessible to developers for a popular use case (full featured DataTable).
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest Angular 4
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: