Enumerated Widgets

Enumerated widgets map database values that computers understand to values that people understand. For example, the value 'M' could map to 'Male', the value '18203' to '3 inch drill bit' or the value 'RWC-14232' to 'Readings in Western Civilization'. Enumerated widgets allow database designers to represent data efficiently within the database -- without requiring users to learn arcane codes or memorize unwieldly abbreviations.

DX provides Enumerated Widget types that make these fields trivial to implement. Because enumerated widgets present users with a finite list of elements to choose from, they must be implemented with a one-of-many Object Type: a Combo Box, Radio Box, List, Option Menu or similar widget.

For example, to create an enumerated widget that maps product_code to product_name using a Combo Box:

  • Select the Combo Box Object Type from the Schema Browser.
  • Drag and drop the product_code on to the Browser. A new application is created.
  • Click on the product_code widget to update the Resource Editor, then find the map resource.
  • Map the name the computer understands to the name the user understands by entering the following in the map resource:

select Products.product_code,Products.product_name from Product

The map resource statement above selects two columns from the Product table: product_code and product_name. The first column specifies the value stored in the database. The second column specifies the value to be displayed and, if selected, mapped to the first column.

Next we'll change the ComboBox settings so that 4 items are displayed in the box. (By default, when you click on the arrow of a combination box, only one choice is displayed.)

  • Locate the mapType resource in the Resource Editor, and change the resource setting to XiDB_MAP_SQL.
  • Locate the visibleItemCount resource, and enter "4" in the visibleItemCount input field.
  • Switch to Play Mode and click on the product code field. A list of product names appears!

Note that these product names are mapped to actual product codes. For example, when users add a product_name, the product_code will be stored in the database.

Additional Resources: