Conditional Format

0
Is there any way of conditionally formatting (colour change) a column in a datagrid such that only entries that meet the condition change format (just like Excel conditional format).
asked
3 answers
3

A 'dirty' trick you can apply, which I believe is possible since Mendix 5.18 is use CSS to select specific elements. In this case a DataGrid's table column will always 'print' the value as "title" element in your HTML. The main benefit of this all is that you can target the title element through CSS.

Example: I have a DataGrid which I give a specific class so that I can target only DataGrids that have this specific class. Let's call it dataGridHighlight. If you inspect your DataGrid in your browser's Development Tools (F12), you'll notice that each table column (<td>) will have a title="" attribute. Let's assume that one of the columns has the value title="NotGood"

By using a CSS selector such the one below, we can target that specific cell and do whatever we want with it in terms of CSS (such as changing background color, text-color, etc.)

.dataGridHighlight td[title="NotGood"] {
        background-color: red;
    }

The above is ofcourse just an example, feel free to make the selector as specific or non-specific as you wish.

The only thing to keep in mind when using this option is that the value you're looking for needs to be included as column in the DataGrid.

answered
1

I don't know if you can colour a column/cell but this app store widget specifies that it is possible to colour a row. You might want to take a look if it fits your needs as well.

https://appstore.home.mendix.com/link/app/877/Flock-of-Birds/Data-Grid-Extension-(Flex-Headers)

answered
0

You can also accomplish a lot with a list view and some creative formatting. If you fill the cells with a table with a single row and make all the columns the same width you should be able to attain a similar effect.

answered