|
for(var i =1;i<=2;i++){
let columnsdetail:ColumnModel[] =[
{ field: 'OrderDate', headerText: 'Order Date', textAlign: 'Right', width: 125, minWidth: 10, format: 'yMd' },
{ field: 'Freight', headerText: 'Freight($)', textAlign: 'Right', width: 100, format: 'C2', minWidth: 10 },
{ field: 'ShipCity', headerText: 'Ship City', width: 100, minWidth: 10, },
{ field: 'ShipCountry', headerText: 'Ship Country', width: 120, minWidth: 10 },
{headerText: 'Ship Region',template:this.template, width: 120, minWidth: 10 }
];
this.columns.push({
headerText: 'Ship Details', columns:columnsdetail, textAlign:'Center'});
} |
|
<div class="control-section">
<ejs-grid [dataSource]="data" [allowPaging]='true' [allowResizing]="true" [columns]="columns" (queryCellInfo)="customiseCell($event)">
</ejs-grid>
<ng-template #template let-data>
<div *ngIf="data.ShipRegion==1">Up</div> //you can get your field value like this
<div *ngIf="data.ShipRegion==0">Down</div>
<div *ngIf="data.ShipRegion==2">Left</div> </ng-template> |
|
[app.component.ts]
customiseCell(args: QueryCellInfoEventArgs) {
if (args.column.field === 'Freight') {
if (args.data[args.column.field] < 0) {
args.cell.classList.add('below-0'); //here we have add the custom class for cells which are negative values
args.cell.innerText = "("+args.cell.innerText +")" // here we have add brackets for cells which are negative values
}
}
}
---------------------------------------------------------------------------------------------------------------------
[app.component.html] <ejs-grid [dataSource]="data" [allowPaging]='true' [allowResizing]="true" [columns]="columns" (queryCellInfo)="customiseCell($event)"> </ejs-grid>
----------------------------------------------------------------------------------------------------------------------- [app.component.css] .e-rowcell.below-0 {
color: red;
} |