How to create dxi-column with dataType dynamically in dxdatagrid?

7.7k Views Asked by At

We are developing an angular application. I have to display records in a dxdatagrid having

  1. Each time the schema will be different.Data coming from different table.

  2. want to add/edit records

  3. want to display controls corresponding to each data type

Any one please help to achieve the same.

1

There are 1 best solutions below

0
Renato Pradebon On

You can use the attribute [columns] on your dx-data-grid.

Example: on your component

const columns =  [{
        dataField: 'id',
        caption: 'Id',
        width: 100,
        dataType: number 
    }, {
        dataField: 'Name',
        caption: 'Name',
        width: 500,
        dataType: string
    }];

on your view

<dx-data-grid id="gridExample"
              [dataSource] = "dataSource" 
              [columns] = "columns">
</dx-data-grid>

References: https://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Configuration/columns/