Selective font styling in grid
I’m trying to change font color for rows in a grid selectively based on an “Enumeration” attribute. Say for an object, the value of that attribute is “YES”, then the font color in that row should be red.
I have used “Grid Cell Styler”
Best widget to change text color or row BG color in data grid.
You should be able to see demo here : https://cellstyler-sandbox.mxapps.io/
Hope this helps,
To achieve this you’ll use the Dynamic row class feature found in DataGrid2
First create a custom .scss file
Open Notepad on your PC and add custom classes like
In the Save as window, change the Save as type to “All files”
Name the file “enum-styling.scss” (Could be any name but it should have .scss)
Save the file in your
project directory > theme > web (You can get there through Mendix Studio Pro: In the top bar, click App > Show App Directory in Explorer) In that same
web folder right click on main.scss and Open with… Notepad then import your file like this
Now in Mendix Studio Pro
DataGrid2 and open its properties Set the
data source and columns Then click on the Edit button next to the
Dynamic row class Your expression should look similar to this
if getCaption($currentObject/myEnumAttribute) = 'YES'
*Replace “myEnumAttribute” with your enumeration attribute’s name
*Keep in mind that
getCaption() retrieves the enumeration’s Caption and getKey() retrieves the enumeration’s Name
*Make sure you save and apply the changes