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.
2 answers

Hi Dheerej,


I have used  “Grid Cell Styler” widget. 

You should be able to write logic in a nanoflow to change text color or also using a javascript. 

Best widget to change text color or row BG color in data grid.

You should be able to see demo here :

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
    color: red;

    color: black;
  • 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
@import "custom-variables";
@import "enum-styling.scss";


Now in Mendix Studio Pro

  • Add a 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'
then 'yes'
else 'no'

*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