Forms elements can be automatically hidden depending on the screen size.
Form element visibility with responsive layout
By hiding some form elements, applications can adapt to the desktop or web browser window size
and to mobile device screen size and orientation, to provide an optimal user experience.
Form elements can be hidden automatically for a given screen size, depending on an abstract size
specification, with the HIDDEN@screen-size attribute syntax.
Important:
Make sure that elements using the
HIDDEN@screen-size attribute do not hide fields used for input
by dialog instructions: The current field that has the focus must always be visible.
In the next example, the customer.cust_address field will be hidden for small
screens, while customer.cust_company will be hidden for small and medium sized
screens, while customer.cust_id and customer.cust_name fields are
the most important data, and must always be visible:
The above example assumes that there are no other form elements related to the address and
company fields. If labels are used for these fields, they should use the same
HIDDEN@screen-size attributes.
Containers such as GRID, TABLE, TREE,
SCROLLGRID, as well as HBOX, VBOX,
FOLDER and GROUP can be configured with the
HIDDEN@screen-size attribute, to hide all the content for a
given screen size:
LAYOUT
VBOX
GRID ( HIDDEN@SMALL )
...
END
...
END
...
Hiding form elements by program
Form elements can be hidden or shown by program, depending on application rules. For example, a
given application user may not have permissions to see some data. This can be implemented with the
ui.Form.setElementHidden() and ui.Form.setFieldHidden()
methods.
Hiding form elements by program can be used in conjunction with HIDDEN@screen-size
attributes, to get responsive layout:
When hiding an element by program (value=1 or 2), it will always be hidden to the user, no
matter the HIDDEN@screen-size definitions.
When showing an element by program (value=0), it will be visible or hidden, depending on the
HIDDEN@screen-size definitions.
Example using HIDDEN@screen-size
The following form definition file uses the HIDDEN attribute with screen-size
specifiers, to indicated what elements must disappear, depending on the screen or container window
size. Note that field11 gets a STRETCH=X attribute, to occupy all the space when the second grid is
hidden.