How do I map choice values to more descriptive strings?


Problem

There are many cases where a particular columns value should be set to one value from a list of choices. In the actual database, the value is often encoded as a numeric value or a code that represents a more descriptive choice that you would like to present. An example is using having the choices: None, Some, Lots, or All representing the values 0, 32, 47, or 100.

Solution

DBPak has a class of graphical objects called enumerated widgets that can be used to solve this problem. Enumerated widgets represent a single column in a form but can take a list of values as possible choices for that field. Examples of enumerated widgets are combination boxes (XiDBComboBox), extended lists (XiDBExtendedList new for version 1.5), radio buttons (XiDBRadioBox), lists (XiDBList) and option menus (XiDBOptionMenu). Each of these widgets have two resources that control the operation of the choice list:

XmNmapType The map type determines where the choices come from. For this example the map type should be XiDB_MAP_STRING meaning the actual and mapped values come from a resource supplied to the widget.
XmNmap The actual values that are mapped. In the example below (from the Database Xcessory XmNmap extended editor) shows two columns of values. The first column is the value returned to the database and the second colum are the values displayed as choices, in this case as radio buttons.

You can map database values to more descriptive strings by setting the XmNmapType resource to XiDB_MAP_STRING and then use the extended editor to map values retrieved from the database to strings. The user must tab between the database value and the string it is mapped to and add new lines at the end of each mapping:


BACK HOME Send Email