|
<button ej-button id='enable' cssClass='e-flat' (click)='add()'>ADD</button>
<ejs-grid #grid [dataSource]='data' [editSettings]='editSettings' [toolbar]='toolbar' height='350'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='CustomerName' headerText='Customer Name' width='150'></e-column>
---------------------------------------------
add() {
var obj = { field: "ShipCity", headerText: 'NewColumn', width: 120 };
this.grid.columns.push(obj as any); //you can add the columns by using the Grid columns method
this.grid.refreshColumns();
}
|
|
<button id='btn' (click)='addColumn($event)'>Add Column </button>
<ejs-grid #grid [dataSource]='data' allowSorting='true' showColumnChooser='true' [toolbar]="toolbar" allowPaging='true' height=365 [pageSettings]='initialPage' [childGrid]='childGrid'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='100' format='C2' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='100'></e-column>
<e-column *ngFor="let col of columns" field='{{col.fieldName}}'
headerText='{{col.headerName}}' width='100'>
</e-column>
</e-columns>
</ejs-grid> |
@Thomas Edwards III Thanks a lot. you have no idea how much you've helped me.
Hi Nahom,
Most Welcome, Please get back to us if you need further assistance with this.
Rajapandi R