Hi Naresh,
Thanks for contacting Syncfusion support.
Query: Is there a way to apply dynamically conditional formatting without refreshing a grid? as I can see in the example. I need to refresh the grid whenever I will apply formatting to a specific cell.
Based your query we suspect that you want to apply the conditional formatting without refreshing the grid component. So, before we proceed to your query, please share the below details to validate further on your requirement.
- Please let us know that you want to change the existing conditional formatting without refreshing the grid component.
- Please let us know that you want to change the conditional formatting with queryCellinfo event?
- Please explain that when you want to change the conditional formatting in your grid application (eg. when performing some actions).
Regards,Ajith G.
|
App.component.html
<div class="control-section">
<ejs-grid #grid [dataSource]='data' height='350' [toolbar]="toolbar" [editSettings]="editSettings"
(queryCellInfo)='customiseCell($event)' (actionComplete)="actionComplete($event)">
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='120' [customAttributes]="{class: 'e-attr'}" format='C2'
textAlign='Right'></e-column>
<e-column field='ShippedDate' headerText='Shipped Date' width='130' format="yMd" textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='150'>
</e-column>
</e-columns>
</ejs-grid>
</div> |
|
App.component.ts
customiseCell(args: QueryCellInfoEventArgs) {
if (args.column.field === "Freight") {
if (args.data["Freight"] > 80) {
(args.cell as any).style.backgroundColor = "red";
}
}
} |
| status | total |
| pending | 12 |
| todo | 43 |
| finished | 98 |
|
App.component.ts
onClick(args) {
this.currentTagetCell = args.target;
this.dialog.show();
}
applyFormate(args) {
switch (this.dropdown.value) {
case "Red":
this.currentTagetCell.classList.add("e-redcolor");
break;
case "Green":
this.currentTagetCell.classList.add("e-greencolor");
break;
case "clear":
this.currentTagetCell.classList.remove("e-redcolor");
this.currentTagetCell.classList.remove("e-greencolor");
break;
}
this.dialog.hide();
} |