Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142590 | Feb 11,2019 03:12 PM UTC | Feb 12,2019 11:41 AM UTC | Angular - EJ 2 | 3 |
![]() |
Tags: Grid |
@Component({
selector: 'control-content',
template: ' <ejs-grid [dataSource]='data' height='350' (queryCellInfo)='customiseCell($event)'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></e-column>
. . .
</e-columns>
</ejs-grid>'
})
export class DefaultComponent implements OnInit {
public data: Object[] = [];
ngOnInit(): void {
this.data = orderDetails;
}
customiseCell(args: QueryCellInfoEventArgs) {
if (args.column.field === 'Freight') {
if (args.data['Freight'] < 30) {
args.cell.classList.add('below-30');
} else if (args.data['Freight'] < 80) {
args.cell.classList.add('below-80');
} else {
args.cell.classList.add('above-80');
}
}
}
} |
<style>
.below-30 {
background-color: orangered;
}
.below-80 {
background-color: yellow;
}
.above-80 {
background-color: greenyellow;
}
</style> |
customiseCell(args: QueryCellInfoEventArgs) {
if (args.column.field === 'Freight') {
if (args.data['Freight'] < 80) {
args.cell.style.backgroundColor ="greenyellow" ; // setting style directly
}
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.