Note: We recommend that you print this tutorial for easy reference. To print, click on the right-hand frame before accessing your HTML Browser's File/Print command.
Most of the time you will probably use textual data fields (such as XiDBDataField) to allow the user to enter data into your application, but sometimes you may want to present the user with a set of choices.
In this tutorial you will create an application that allows the user to choose one salesperson from a list of all salespeople and displays all of that salesperson's sales (invoices) in a table. We'll use an XiDBCombinationBox for the one-of-many choice.
Use the following steps to create the application:
One Column Added as a Combination Box to the Interface
Enumerated widgets retrieve their choices from their XmNmap resource, in a way that is determined by the value of the XmNmapType resource. You will set XmNmapType to XiDB_MAP_SQL, which says that the XmNmap specifies an SQL statement that lists the choices.
The default setting for the map resource is XmNmap_Unset. The map resource has a text input field, so double-click on the default value and delete it to clear the input field.
The value of the widget is the first column--in this case, the employee ID. By specifying a second column, we are saying that the value in the second column (the name of the salesperson) should be displayed in the widget and then mapped to the first column value (for example, Employee_Id) if it is selected. We're doing this here so that we can select by name, but then use the corresponding Employee_Id in a join.
This resource should be located directly below the map resource.
By default, this resource is set to XiDB_MAP_STRING. Instead of a text input field, this resource presents an option menu of settings. Select XiDB_MAP_SQL from the option menu items.
All Possible Settings Displayed for mapType Resource
By default, when you click on the arrow of the combination box you have created, only one choice will be displayed. The visibleItemCount resource determines how many items will be displayed when you click on the arrow.
The next step is to create the table.
A table of the selected Invoice columns is created on your interface.
Although the combination box is connected to a query, you will not use that query in the search. The table acts as the query for the purposes of searching.
All Columns from Invoice Table Added to Interface as a Table
Either click on the dbTable object on the Browser hierarchy, or click on the table on the interface to select it.
Or use the mouse to resize the table. For example, use MB1 to drag the bottom edge down. The purpose of resizing the table is to display more data at once.
The table should now look like:
Resized Table
Once you have created the table, the next step is to set resources for it:
where
resource.where
input field, enter "Invoice.Employee_Id = @value(sales_Employee_Id)" to set the where
clause to retrieve only those invoices that correspond to the currently selected salesperson.You can now go into Play Mode and test the application:
Combination Box Choices Displayed
Information Associated with Customer Name Displayed in Table