Dynamic classes Data grid cant access the entity or $currentObject
Hi I am trying to add some conditional formatting on a Data view. What I would like to do is when a system is equal to a name, to change the background color of that element by using the built-in Mendix styles/class. When I attempt to add the xpath function on the appearance I get an error that it can’t locate the $currentObject and when I try the attribute path I get the error that It can’t locate that either. Is there something that I am missing to set that will give me access? I want to avoid having to upload a SASS file and trying to do it with what can be done within Mendix. I am using Studio Pro 9.6.10 and below is the xpath that I have tried within the Dynamic classes section: if $currentObject/System = 'CRU-131-INC-065-22' then 'background-warning' else 'background-primary' if ProductImportModule.SystemImport/System = 'CRU-131-INC-065-22' then 'background-warning' else 'background-primary' Here is a sceenshot to help show what I am trying to do.
From what I can tell, you don’t have access to $currentObject because this is a datagrid, not a dataview. Intuitively, I feel like this should work but it seems like Mendix doesn’t like it. If you had a containing dataview around this datagrid, the object from the dataview is what would be accessible here via $currentObject, but I know that’s not what you’re trying to do.
To get what you want with mendix, maybe use a listview with two visibility controlled containers based on the system, each with the respective background color you want for the given system. I’m not super familiar with the datagrid 2 but that may also be a viable option that provides a little more flexibility for styling/formatting than a normal datagrid.