Displayif (attribute of property)

From JRapid

(Redirected from Displayif)
Jump to: navigation, search

displayif is an attribute of property.

Contents

Description

The displayif condition specifies whether or not an element is visible.



The displayif may be used with:


Elements that are not displayed do not take up space on the form. Use the displayif attribute to create invisible elements that take up space on the form.

The displayif attribute value is an FPath expression that must return a boolean result. This expression enables the developer to query the current value of the form properties in order to check a condition.

Usage

<property
   ...
   displayif="FPATH_CONDITION"
   ...
/>

Examples

A common condition for hiding a property is depending on a boolean property. This example shows the form for a Person entity and how a "tip" html element and a "spouse" property of type text are displayed only when the boolean property "isMarried" is marked as true.

Note that the condition checks for the empty value first, as the "isMarried" boolean property has a null value when the form is opened for a new Person.

When not displayed, the html element and the "spouse" property do not take space on the form. Use visibleif to hide elements while still taking up space.

 <entity label="Person" menu="Menu" name="Person">
        <html name="tip" displayif="isMarried = '' or isMarried = 'false'">
            <![CDATA[Check the Is Married field to make the spouse field<br/>
            visible and hide this message.<br/><br/>]]>
        </html>

        <property display="primary" label="Name" name="name"/>
        <property label="Is married" name="isMarried" type="boolean"/>
        <property label="Spouse" name="spouseName" displayif="isMarried != '' and isMarried = 'true'" />
 </entity>


Displayif condition with boolean example


Another common situation is when a property or element must be shown only when the record has already been persisted t the database. That is, if the form is editing a new record, do not show a specific property. The expression for this condition is written as follows.

 <entity label="Person" menu="Menu" name="Person">
        <property display="primary" label="Name" name="name"/>
        <property label="Spouse" name="spouseName" displayif=". > 0" />
 </entity>

This expression stands for: "if current record id is greater than zero". This is because the "." represents the current record id and when a form is editing a new record, the id is set to zero.

See also

Personal tools