...
1. 'choices/values' properties - The
- Choice option field - Is where your fields are selected in order how you would like the auto-complete to display them.
- Choice values field - Is where the value you want returned to your application is set.
Here 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. Apple, Orange, Banana).
- 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"] ) within the choices and choice values fields also allows you to populate the auto-complete, these fields can also be bound to an RPG field (Rich UI only).
2. Database-Driven Auto-Complete - See Database-Driven Auto-Complete section below.
Web service - You can pass JSON through a web service such as a PHP program to complete the choices and choice value fields (see choices URL example below).
Database-Driven Auto-Complete
This section allows choices/values to be retrieved from a database file. In order to use this, simply enter the name of the database file, the name of the choice option field(s) you would like to search by, and the name of the choice value field you wish to return the value of to your application.
Selecting Multiple Columns
Choices database file - Enter the database file to use to populate your options/values.
Choice options field - Select the field(s) you wish to use to search. If there are multiple fields specified in the choice options field this will allow you to return multiple values in the auto-complete search. However, only the first value in the field will be used to search, any other selected fields are for display only as additional columns.
Choice values field - Select the field to return a value to your application.
In the example, records will be loaded from file CATEGP. The records will be searched on field CNAME and CATID, with field CATID displaying in a second column (see below). The value in field CATID in the selected record will be returned to the program.
SQL Expressions
You can also use SQL expressions to return information in addition to just selecting database fields from the file. So in the example, using the expression TRIM(CNAME) || ', ' || CATID allows us to return a concatenated search value with formatting for our search, but the returned value to the application is unchanged.
...
Example of the showErrors() API displaying the JSON error example:
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"] ) within the choices and choice values fields also allows you to populate the auto-complete, these fields can also be bound to an RPG field (Rich UI only).