Tutorial Chapter 12: Changing the User Interface Dynamically |
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:
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.
CALL f1.setFieldHidden("state_name",1)
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.
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
Figure 1. Form before hiding element
Figure 2. Form after hiding element