hub.eb?material_id=323&track_id=298

Dynamic Lists


A Dynamic List loads its list items from a database at runtime by executing a SQL select statement to extract display and return values from a database table.

List Fields can be added to hold data returned by the SQL statements. Those that match the name of a column are automatically populated with the values from that column. Both the column and List Field names are case-sensitive.

List Fields can also be used as parameters in the SQL statement to filter its results, for example, in the WHERE clause.

A Dynamic List can be associated with a Field or Table Column in their Properties View. The Dynamic List Mappings property allows a List Field to be selected as the display and return values for the Field or Table Column. Other List Field-to-Field mappings can also be configured so that queries that use those List Fields in the Dynamic List's SQL statements have appropriate values.

The When List Is Built property of the Field determines the generation strategy of the Dynamic List:

  • First Display generates the List the first time associated Field Controls are shown.
  • Each Display generates the List every time the Page is displayed or refreshed.
  • Never the List generation must be triggered programatically.

You can programatically generate a Dynamic List, via its associated Field or Table Column, using the JavaScript API:

fields.myField.list.buildList();

This can also be used to generate or regenerate the List when the Field's When List Is Built property is set to First Display or Each Display.

Steps


1

Create the following database tables:

Countries

country_id name
GB United Kingdom
US United States

Cities

country_id city_id name
GB LDN London
GB CAR Cardiff
GB DUB Dublin
GB EDN Edinburgh
US SFO San Francisco
2

Create a new Form with two Fields: country and city and add drag them onto the Page.

Set the city Field's Display Type to Dropdown.

Enable Immediate Validation for the country Field Control.

3

Create a new Dynamic List called citiesList.

Select the Database Connection to connect to your database and add the SQL and List Fields as follows:

Save the List.

4

Associate citiesList to the city Field on the Form.

Choose name as the Display Field and city_id as the Return Field.

Map the country_id List Field to the country form Field.

Set the city Field's When List Is Built property to Each Display.

5

Run the Form, enter GB in the country field.

The city dropdown will list the cities in Great Britain.

Current Module

Related