When the list of items gets longer, classifying the items becomes helpful. For example, we may want to arrange our shopping list by department in the supermarket.
We will add a 'Category' column to the item table and show how we let the user select a category from a list of categories managed in the system.
Using the 'Table Wizard':
The wizard will update your model with the additional field in all relevant places. If you now save your model and restart the application, you will be able to specify a category for any item you choose:
The wizard has used the mechanism of user defined data types with valid values, and then created a Chooser filed using the user defined data type. If you start the application, you will see that the Category field is represented by a drop-down list that lets the user choose one of the 3 values we have specified (Dairy, Drinks or Meat).
Click here to read more on valid values and user defined data types.
Specifying the list of valid values explicitly in the Table Wizard is probably good enough for our simple Shopping List application, but we may want to give the users the ability to manage the list of categories.
This can be achieved by creating a table of categories and specifying that the 'Category' field in 'Items' will refer to this table (i.e. specify the valid values through a foreign key that references the table of categories).
Here are the steps to create and use a table of categories:
The user can easily sort the table of items by categories.
After launching the application, click the 'Category' column title to sort the items in ascending order of their categories (indicated by a small up-pointing rectangle at the column title).
A second click on the 'Category' title will reverse the sort order (note that the small rectangle at the column title is now pointing down). A third click disables the sort.
Sorting can be made by any other field as well. Since the Table Wizard contains a built-in sorting mechanism, you can click the title of any column in the table. You can sort the table by one column or several columns.
Download Model: Stage 7, Final Model (version 2.1.9)
Try It Online
Next: Controlling which items to show
For best results, use the Firefox browser..