using version: 14.2.20141.2477
How do you currently recommend setting the background color of a grid cell dependant on the cell's value?
The only relevant material I could locate is this
Regards
Aidan
Hello Aidan,
Thank you for posting in our community.
What I can suggest for achieving your requirement is using conditional templates. They let you use if conditions to determine what content to render in the cell to be template. Conditional templates could be set for particular column via the template property. The content of the template should be the HTML markup that goes in the table cell, without any tags included. In your scenario you could use a div element to wrap the cell value and set the div`s background color based on the cell value. For example:
$("#grid").igGrid({ columns: [ { headerText: "Product ID", key: "ProductID", dataType: "number" }, { headerText: "Product Name", key: "Name", dataType: "string" }, { headerText: "Product Number", key: "ProductNumber", dataType: "string" }, { headerText: "Availability", key: "Availability", dataType: "number", template: "<div style='background-color: {{if ${Availability} > 10}}chartreuse{{else}}coral {{/if}}'>${Availability}</div>" }, ], width: "500px", dataSource: products });
I am also attaching a small sample illustrating my suggestion for your reference. Please have a look at the sample and let me know if you need any additional information regarding this matter.
Additionally, there is a working sample illustrating how conditional templates work in our online samples browser at the following link:
http://www.igniteui.com/templating-engine/conditional-templates
I hope you will find my sinformation helpful.
Please let me know if you need any further assistance with this matter.