How to access DataGrid attributes inside DataGrid column for dynamic styling?

0
I have a DataGrid linked with an entity that has 3 attributes, for example - income, expense, and remainder.   I need to apply dynamic styles to the third column so that if the difference between income and expense is a positive number, the remainder will be green, and if the number is negative, it will be red.   But I can't apply a normal expression because as I can see I can't access any attribute of the DataGrid Entity inside the DataGrid Column.   What would you recommend? Is there a way to implement dynamic styles in this example without replacing the DateGrid widget with a different one?
asked
3 answers
4

Hi Maxim Velichkin,

I found solution has been provided by Tim v Steenbergen for the same question-
https://forum.mendix.com/link/space/widgets/questions/105921.

He suggested to use the GridCellStyler widget from appstore to styling cells or rows of data grid.

I haven’t tried it yet, but seems to be interesting and surely excited to try it out.

Hope this helps you.

Thank you.

answered
2

Hi Maxim,

 

the solution Rahul is suggesting is probably the solution you’re looking for.

 

In addition to his answer, I added some printscreens of the functionality. 

 

Editing the rule:

 

In my case a nanoflow gives the boolean to apply styling or not. 

answered
2

HI Maxim,

for the datagrid columns you can directly write the dynamic classes based on your conditions you wish don't add the default class to the column create two classes green and red where based on if else condition in the dynamic classes.

if the above solution not works

https://forum.mendix.com/link/space/widgets/questions/105921

use the above link for probable solution.

 

 

answered