How to generate dxi-column list dynamically from typescript?

1.9k Views Asked by At

We are developing an angular application. dxdatagrid is used to display data. In dxdatagrid is it possible to generate columns from typescript?

Please see the below code snippet

< dx-data-grid id="EmployeeGrid"

            [dataSource]="EmployeeList">        
    <dxi-column dataField="FirstName"></dxi-column>
    <dxi-column dataField="LastName"></dxi-column>
</dx-data-grid>

Here I want to generate the "FirstName" and "LastName" from Typescript.

Please any one help to achieve the same

Thanks

Krishnan

1

There are 1 best solutions below

0
chanchaw On

this is my code:

<dxi-column *ngFor="let col of cols" dataField="{{col.dataField}}" caption="{{col.caption}}"></dxi-column>
cols is a attribute in ts file, and it is array,so the column count is the length of array