question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic Columns in md table

See original GitHub issue

Bug, feature request, or proposal:

I guess is a bug

What is the expected behavior?

  1. Load columns definitions via httpService
  2. Load data.
  3. Show Data Table.
  4. Be happy.

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 {

displayedColumns = [];
private dataSource: ProductoDataSource | null;

meta: any = {
    attributes: []
};


constructor(private displayService: DisplayService) {
   }


ngOnInit() {
    this.displayService
        .ObtenerTabla("PRODUCTOS")
        .subscribe(meta => {
            meta.Columnas.forEach(x => {
                this.meta.attributes.push({ label: x.Nombre, name: x.Propiedad });
                this.displayedColumns.push(x.Nombre);
            });
            //this.dataSource = new ProductoDataSource(this.apiService);
        });
}

} `

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

32reactions
fnotecommented, Aug 28, 2017
<md-table #table [dataSource]="dataSource" mdSort>
	    <ng-container *ngFor="let col of displayedColumns" cdkColumnDef={{col}}>
		    <md-header-cell  *cdkHeaderCellDef md-sort-header> {{ col }}</md-header-cell>
		    <md-cell  *cdkCellDef="let row"> {{row[col]}}</md-cell>
	    </ng-container>

this is how i did it…

0reactions
angular-automatic-lock-bot[bot]commented, Jun 2, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic columns table - Material Design for Bootstrap
My ultimate goal is to create datatables in a dynamic way, with all its functions of ordering, searching, page, etc. There's no built-in...
Read more >
Table dynamically changing the columns displayed - StackBlitz
Table dynamically changing the columns displayed.
Read more >
Dynamic table with 2 columns based on array length
Now I have table which I can fill the data from array, but only if array length matchs table row. <div class="tab-pane" id="adv">...
Read more >
Creating Dynamic Markdown Tables in Podio Calculation Fields
I recently figured out how to make 100% Dynamic Markdown Tables in Podio. You can create tables with as many rows and/or as...
Read more >
Dynamic Table - UMB Website Manual
Add the Dynamic Table content type to a page to create the dynamic table and configure the column headers and other settings. To...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found