Error when trying to use dynamic classes

0
Hi all,   I am relatively new to Mendix. I have been developing an application, where I wanted to associate dynamic behavior on certain widgets. Namely, I wanted to disable certain widgets, when a certain condition holds.   I have a non-persistable object which holds a boolean attribute to drive this behavior. If the attribute is false, I do not associate any classes, otherwise I set the widget to disabled via dynamic class.   In order to do this, I put this expression in the dynamic classes field of my widget (in this case it is a container, however I get the same error no matter which widget I try).   if ($PatchPageProperties/IsEditModeActive) then 'disabled' else ''   I get this error no matter where I try to add this dynamic class expression   CE0455 An expression is configured even though there is no data container.   The problem has nothing to do with non-persistable data. Even if I write something else in the dynamic classes box, I get the same error.   Any idea why I may be getting the error?
asked
3 answers
1

It is in fact exactly what the error says. You need to put the widget inside of a datacontainer.

In this example, the test text widget is outside of a container, resulting in the error.

image.png

If I put it inside the Dashboard the error is gone

image.png

Furthermore, I can now use any attribute in my Dashboard object (referred to as $currentObject) to display the required information like

if $currentObject/IsEditModeActive then 'disabled' else ''

answered
0

You need to point to the npe from the expression on the page. To this by adding a page parameter or adding a dataview to the page where the element holding the dynamic expression is in. 

answered
0

Rather than using dynamic classes, you may find it easier to use the Visibility section on the widgets and other elements on the page.

 

https://docs.mendix.com/refguide9/common-widget-properties/#visibility-properties

 

If you want to conditionally display content, this is usually the best method.

 

Good luck!

answered