[app.component.html]
<ejs-grid #grid [dataSource]='data' allowPaging='true' (load)='load($event)' (dataBound)="dataBound($event)">
</ejs-grid>
[app.component.ts]
export class AppComponent {
public data: Object[] = [];
public isinitialLoad: boolean = false;
@ViewChild('grid', { static: false }) public grid: GridComponent;
load(args) {
this.isinitialLoad = true;
}
dataBound(args) {
if (this.isinitialLoad) {
for (let i: number = 0; i < this.grid.columns.length; i++) {
if (this.grid.columns[i]['field'] === "ShipRegion" || this.grid.columns[i]['field'] === "ShipAddress" || this.grid.columns[i]['field'] === "ShipName") {
this.grid.columns[i]['visible'] = false;
}
else{
if(this.grid.columns[i]['field'] === 'OrderDate' || this.grid.columns[i]['field'] === 'ShippedDate'){
this.grid.columns[i]['format']= 'yMd';
}
if(this.grid.columns[i]['field'] ==='Freight'){
this.grid.columns[i]['format']= 'C2';
}
if(this.grid.columns[i]['type'] ==='number'){
this.grid.columns[i]['textAlign']= 'Right';
}
}
}
this.isinitialLoad = false;
this.grid.refreshColumns();
}
}
ngOnInit(): void {
this.data = orderDetails;
} |