Hiding Form Items
You can use Form
class methods to change the value of the
hidden
property of form items, hiding parts of the form from the user.
Interactive instructions such as INPUT
or CONSTRUCT
will
automatically ignore a formfield that is hidden. The value can be:
0
- the form item is not hidden; it is visible1
- the form item is hidden and cannot be made visible by the user2
- the form item is hidden, but the user can make it visible, using the context menu for a table, for example
By default, all form items are visible.
Call the methods using the reference to the form object. Provide the name of the form item to the method and set the value for hidden.
setFieldHidden()
- this method can be used to hide formfields only. The prefix in the name of the formfield (tablename.
orformonly.
) is optional:CALL f1.setFieldHidden("state_name",1)
setElementHidden()
- this method hides any form item, including formfields. If the item is a formfield, the name must include the prefix:CALL f1.setElementHidden("lb1", 1) CALL f1.setElementHidden("state.state_name",1) CALL f1.setElementHidden("formonly.pflag",1)
Genero adjusts the display of the form to eliminate blank spaces caused by hiding items, where possible.
Example 3
01
SCHEMA
custdemo
02
MAIN
03
DEFINE
win ui.Window,
04
fm ui.Form,
05
mycust record like customer.*
06
CONNECT TO
"custdemo"
07
OPEN WINDOW
w1 WITH FORM
"hidecust"
08
SELECT
* INTO
mycust.* FROM
customer
09
WHERE
store_num = 101
10
DISPLAY BY NAME
mycust.*
11
LET
win = ui.Window.getCurrent()
12
LET
fm = win.getForm()
13
MENU
14
ON ACTION
hide
15
CALL
fm.setFieldHidden("contact_name",1)
16
CALL
fm.setFieldHidden("addr2", 1)
17
-- hide the label for contact name
18
CALL
fm.setElementHidden("lbl", 1)
19
ON ACTION
quit
20
EXIT MENU
21
END MENU
22
END MAIN