Choices
Contents
See Also
Advanced Canvas Control Attributes, Autosuggestions, Data Attributes, Data Mapping, Field Attributes, Grid Columns, Help Attributes, SQL SELECT, SQLVALUES(), Working with the Lianja Object Model
Overview
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:
Attribute | Description |
---|---|
Choices | The list of choices |
This can be set in the Table Designer ('Create a Column' and 'Modify a Column' dialogs prior to v6.3) in the Data Workspace and Page Builder or specified in the CREATE TABLE and ALTER TABLE commands.
open database southwind // Static choices ALTER TABLE "example" MODIFY CONSTRAINT TITLE SET CHOICES "Mr,Mrs,Ms" // Dynamic choices @tablename,expression ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "@customers,customerid" // Dynamic choices SQL Select ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "select customerid from customers"
Static Lists
Static lists are based on a comma-separated list of choices.
Choices: Buchanan,Callahan,Davolio,Dodsworth,Fuller,King,Leverling,Peacock,Suyama
In edit mode, clicking in the field displays the dropdown of choices.
Dynamic List
A dynamic list is based on the evaluation of an expression from a specified table.
@<table-name>,<expression>
Here the list is based on the current values of the lastname field from the employees table.
Choices: @employees,lastname
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).
{UserDefinedFunction()}
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.
Choices: {getempname()}
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
Attribute | Notes |
---|---|
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. |
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.
- The Choices attribute can be queried or changed programmatically in JavaScript scripting on the Web/Mobile client using Lianja.getElementByID("page.section.field").choicelist.
- For Grid columns (Desktop client), the attribute is referenced as follows:
Lianja.getElementByID("page.section").grid.columns(n).choicelist