Choices provide a choice list for the user in a Form field, Grid Section column or Canvas Section combobox.
The choices are displayed in a dropdown under the control. Clicking on a choice loads its value into the field. The field itself cannot be edited.
Choices can be:
- Static list
- Dynamic table-based list
- SQL Select based list
- User defined function based list
Choices are defined in the Choices field attribute found in the Data sub-section of the attributes dialog:
|Choices||The list of choices|
Or in the Choices field attribute in the Create a Column and Modify a Column dialogs in the Data Workspace and Page Builder.
Static lists are based on a comma-separated list of choices.
In edit mode, clicking in the field displays the dropdown of choices.
A dynamic list is based on the evaluation of an expression from a specified table.
Here the list is based on the current values of the lastname field from the employees table.
The dropdown displays values from the table.
SQL Select List
A SQL Select list is generated by the resultset from a SQL Select statement.
Here the list is based on the ordered current values of the lastname field from the employees table.
Choices: select lastname from employees order by lastname
The dropdown displays values from the resultset.
Note: to display a blank value at the top of the choice list, prefix the SQL Select statement with a '+'.
Choices: +select lastname from employees order by lastname
User Defined Function
The list can be based on the return value from a user defined function or procedure (Lianja/VFP scripting).
The return value should be a comma-separated list. Here the list is based on the return value from the 'getempname' procedure defined in the App's custom library.
As in the other examples, it returns the lastname field values from the employees table.
proc getempname() sqlvalues("select lastname from employees order by lastname") creturn = astring(_sqlvalues) return creturn endproc
The dropdown displays values from the list returned by the procedure.
Notes on Client Support
|Choices||For Form Section fields and Canvas Section comboboxes:|
Static and SQL Select lists are supported on all clients.
Dynamic and user defined function lists are currently supported on the Desktop client only.
Grid column Choices lists are supported on the Desktop client only.
Notes on Scripting Support
- The Choices attribute can be queried or changed programmatically in Lianja/VFP scripting on the Desktop client using Lianja.getElementByID("page.section.field").choicelist.
- For Grid columns (Desktop client), the attribute is referenced as follows: