Hi
I have below lines to get data from parent . I am using Angular material table. I want to display Headers,Columns dynamically in Angular Material table.
TypeScript
@Input() arrHeader: any = [];
@Input() arrGrid: any = [];Thanls
Hi
I have below lines to get data from parent . I am using Angular material table. I want to display Headers,Columns dynamically in Angular Material table.
@Input() arrHeader: any = [];
@Input() arrGrid: any = [];Thanls
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Jun 24, 2024, 2:07 AM EDT
To dynamically display headers and columns in an Angular Material table, you can utilize the
@Inputdecorator in Angular. By passing the header and grid data from the parent component to the child component, you can dynamically populate the table.import { Component, Input } from '@angular/core'; @Component({ selector: 'app-dynamic-table', template: ` {{ header }} {{ element[header] }} `, }) export class DynamicTableComponent { @Input() arrHeader: any = []; @Input() arrGrid: any = []; }The
DynamicTableComponentreceivesarrHeaderfor headers andarrGridfor grid data. By iterating overarrHeaderand dynamically creating columns, you can achieve a dynamic Angular Material table.Ramco RamcoRank #462 · 5.4K reputationPosted Jun 24, 2024, 2:40 AM EDT
Hi Jayraj
If i have below code for Header what changes i need to do in Dynamic Table Html.
arrheader = [ {'Head': 'Category','FieldName': 'categoryName'}, {'Head': 'Name','FieldName': 'productName'}, {'Head': 'Description','FieldName': 'productDescription'}, {'Head': 'Price','FieldName': 'productPrice'} ]Thanks