The list box acts like an expanded Select Box. The list box can be used for a single choice, or multiple choices from a list.
Field Binding Dialog (Rich UI Only)
(Input link to Field Binding page under Widget section)
Choices / Choice Values Properties
These properties can be used to set the list of options in the list box:
- choices property - Is where your set the options in order how you would like the select box to display them.
- choice values property - Is where the value you want returned to your application is set.
One option will appear in the box for each entry in the 'choices' list. The value for each choice will be taken from the corresponding entry in the 'choice values' list. If 'choice values' is not specified, the 'choice' text will also be used as the value.
These fields can also be bound to an RPG field (Rich UI only).
There are two ways to populate the choice option/values properties:
- Comma separated list - A simple list of values separated by just a comma (i.e. Option 1, Option 2, Option 3, etc...).
JSON array format - Using JSON array format, meaning the choices/values are enclosed in a bracket with quotations and then comma separated (i.e. ["ElementOne", "ElementTwo", "ElementThree"] ) within the choices and choice values fields also allows you to populate the auto-complete.
This section allows choices/choice values to be retrieved from a database file.
Choices database file - Enter the database file to use to populate your options/values. When setting your database file it's not required to qualify with library name, although you can. if the library is omitted, the application job's library list will be used.
Choice options field - Select the field you wish to use to populate the values shown as choice options.
Choice values field - Select the field to return a value to your application.
In the example, records will be loaded from file CATEGP. The options will be populated by field CNAME. The value in field CATID in the selected record will be returned to the program.
Choice selection criteria - This acts as a WHERE clause in an SQL statement to filter your criteria. SQL parameter markers are always specified by a question mark (?). The property "choices parameter value" can be used to provide the value for this parameter marker.
This will produce an SQL statement like this:
Choice parameter value - This is where the choice selection criteria value for '?' is set. This value may also be bound to a field (Rich UI only).
By completing the choice parameter value we can see our statement should return only the items named "Soaps". You can have multiple "parameter value" properties, however this does require multiple choices selection criteria. These can be added by right-clicking the choices parameter value property name and selecting "Add Another Choices Parameter Value":
To find more information on the choice selection criteria and choices parameter properties, view the Parameter Markers section here.