How to show/hide a section or control grid depending on a number field in the UI designer

I have a data model containing a number field with an amount. Depending on whether that field is filled there is another field în its own group that is computed based on the value of the amount.

I would like to display the computed field in its own section in the ui designer, but only show this section if the field with the amount has been filled.

How can I show/hide this section depending on whether the field with the amount is filled?

The UI designer doesn’t allow me to specify a dependent controls or dependent groups/fields.

The data model for example is this:

<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="http://www.mgm-tp.com/a12/picus/model/v2">
    <metadata>
        <name>DomainFoo</name>
        <languages>en</languages>
        <annotation name="roles">admin</annotation>
        <comment/>
        <savedAt>2019-11-01T09:17:28.662+01:00</savedAt>
        <schemaVersion>22.6.0</schemaVersion>
    </metadata>
    <group max="1" id="group_a40fa" name="Base">
        <field id="field_0bb2a" name="Value">
            <number trait="amount"/>
        </field>
    </group>
    <group max="1" id="group_93b02" name="Derived">
        <field id="field_94dcf" name="ValueGross">
            <number trait="amount"/>
        </field>
        <computation id="computation_56993" name="ValueGrossComputation">
            <fieldIdRef>field_94dcf</fieldIdRef>
            <errorCode/>
            <errorCondition>FieldFilled(ValueGross) and ( (  FieldFilled(/Base/Value) and  [ValueGross] != [/Base/Value] * 1.19  ) )</errorCondition>
            <errorMessage>
                <text lang="en">error text for computation of ValueGrossComputation</text>
            </errorMessage>
            <severity>error</severity>
        </computation>
    </group>
</model>

Hi @andreas-fresh-mesa,

From my experience, it’s not possible to hide/show a control grid based on a number field but it has to be a boolean/confirm/enum field.

I could see now that there is a way to do it. Basically I created another computation for a boolean field based on the condition that Base/Value is filled or not. After that, the display of ValueGross will be depended on the value of the boolean field.

Please have a look in the example models below and see if that way could be used in your project. :slight_smile:
DomainFoo.xml (1.9 KB) Foo.xml (2.1 KB)

please don’t modify the xml directly in order to use number field as master field even by chance it works the only way to modify your model is using the tool. If the tool doesn’t support then please create requirement for it.

Hi Andreas, this hiding is possible to be done by regular A12 mechanisms:

  • define a boleen field, say, toBeHidden
  • define a computation in the data modeler *(fieldFilled(foo)) → True" for result field toBeHidden
  • define in the ui modeler a dependent field dependency with trigger toBeHidden setting for value True property “hidden”
  • finally hide the field toBeHidden by specifying a tautology for it (i.e. hidden for some other boolean or enumeration field, for any value)

Regarding the last bullet, we asked for some improvement on that but I think this at least a good workaround, meanwhile. See <INTERNAL_LINK>