[app.component.html]
<ejs-grid class="sortingenabled" [dataSource]='data' allowPaging='true'>
<e-columns>
<ng-template ngFor let-column [ngForOf]="columns">
<e-column [field]="column.field"
[headerText]="column.headerText"
[allowEditing]="column.allowEditing"
[isPrimaryKey]="column.isPrimaryKey != null ? column.isPrimaryKey : null"
[width]="column.width">
</e-column>
</ng-template>
</e-columns>
</ejs-grid>
---------------------------------------------------------------------------------
[app.component.ts]
export class AppComponent {
public data: Object[];
public columns: any;
public jsonHeaderText: object[];
constructor( ) {
}
public ngOnInit(): void {
this.data = data.slice(0,50);
this.jsonHeaderText = [{"OrderID":"Ordering Detail",
"CustomerName":"Customer Name Detail","ShipCountry":"Shipping Country",
"OrderDate":"Ordering Date"}];
this.columns = [{ field: 'OrderID', headerText: this.jsonHeaderText[0]["OrderID"] , isPrimaryKey: true, width: 120, textAlign: 'Right' },
{ field: 'Freight', width: 125, format: 'C2' },
{ field: 'CustomerID', headerText: 'Customer ID', width: 130 },
{ field: 'ShipName', headerText: 'Ship Name', width: 180 }];
}
}
|