-
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
Dynamic Columns in md table #6159
Comments
Dynamic column definitions (using ngFor to stamp out column definitions) were added in #5545 and are not yet released. Plunker uses a build based off the latest master so that's why it works there. To install the latest build, run this to install and save it to your npm package:
|
@andrewseguin Thank you |
this is how i did it.. |
Any additional documentation on how to get this working? neither @Fnote 's comment nor the https://material.angular.io/components/table/examples seem to show how dynamic columns would work. |
There's no extra documentation yet, but if you have any specific questions feel free to ask them here. You should be able to dynamically change the column definitions as well as change the header and row's column inputs |
It appears that this will show the columns and all my rows, but row[col]
is undefined. I'm using the samples from the documentation. I suspect I need to setup displayedColumns as an object of some type to make this work, however what property (or name should I call it) will be shown in each row?
<ng-container *ngFor="let col of displayedColumns" mdColumnDef="{{col}}">
<md-header-cell *mdHeaderCellDef> {{col}} </md-header-cell>
<md-cell *mdCellDef="let row"> {{row[col]}} </md-cell>
</ng-container>
I see this in your checkin. I could attempt to create a dynamicColumnDefs object
this.dynamicColumnDefs.push({
id: nextProperty.toUpperCase(),
property: nextProperty,
headerText: nextProperty
});
…On Mon, Sep 11, 2017 at 12:28 PM, Andrew Seguin ***@***.***> wrote:
There's no extra documentation yet, but if you have any specific questions
feel free to ask them here. You should be able to dynamically change the
column definitions as well as change the header and row's column inputs
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6159 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APgcp_oOk0jmW_IL5MGQ2dCrWFmYW1qBks5shXdwgaJpZM4OnyvS>
.
|
@wooddani there's an open issue (#5927) for adding docs on this Maybe #5927 (comment) will help you. |
MatTable don't support empty rows and/or columns, which is my case right before an initial request is responded. |
@Fnote tnx |
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:
I guess is a bug
What is the expected behavior?
What is the current behavior?
1.Load columns definitions via httpService.
2. Crash -> Error: cdk-table: Could not find column with id "FooColumn".
3. No Show Data Table.
4. Be sad and cry for two hours.
What are the steps to reproduce?
table.template.html
<md-table [dataSource]="dataSource"> <ng-container *ngFor="let attr of meta.attributes"> <ng-container [cdkColumnDef]="attr.name"> <md-header-cell *cdkHeaderCellDef >{{attr.label}}</md-header-cell> <md-cell *cdkCellDef="let row"> {{row[attr.name]}} </md-cell> </ng-container> </ng-container> <md-header-row *cdkHeaderRowDef="displayedColumns"></md-header-row> <md-row *cdkRowDef="let row; columns: displayedColumns;"></md-row> </md-table>
table.component.ts
`
export class ProductosComponent implements OnInit {
}
`
Is there anything else we should know?
I found this example
https://plnkr.co/edit/WKlClMq39ZOUBaQ7NhKx?p=preview
just add *ngIf="meta.attributes.length' for load the table when all is loaded,
but when I do this the table don't displayed.
Sorry for my english.
Thanks in Advance.
The text was updated successfully, but these errors were encountered: