 Establishing relationships between models The gadget spec URL could not be found
In this chapter, we will learn to establish the relationships between the data models. Firstly, we will implement a reference look-up relationship between the category model and product model, and then implement a parent/child relationship between the product model and product color model.
 Implementing a reference look-up relationship
The first step is to create the product model under catalog menu and then establish a reference look-up to the category model.
|
| Create product model under catalog menu |
|
Click on the new model icon. |
|
|
|
|
|
A dialog box will be displayed. Select the "Catalog Menu" folder, enter the model name as "Product" and then click on the create model button.
|
|
|
| Add parameters to the product model | | |
|
Use the add new parameter button to add the following parameters to the product model.
- Product Code, "Text" - Product Description, "Text" - Product Price, "Number" |
|
|
|
| Create category code reference look-up | | |
|
The category code parameter must be added to the product model. This parameter can take only valid category code values from the category model. Hence, a reference look-up to the category model can be created.
Click on the add new parameter button. |
|
|
|
|
| Since we are trying to establish a reference relationship, click on the reference button. |
|
|
|
|
| Enter "CategoryCode" in the name field. |
|
|
|
|
|
Select "Category" from the dropdown list for model. This dropdown will list all the models in the application. |
|
|
|
|
|
Once a model is selected, additional properties such as "display cell", "parent/child" and "sort by" will be displayed.
Select "No" for parent/child field because we are creating a reference look-up. |
|
|
|
|
|
Select "CategoryCode" from the dropdown list for display cell.
Whenever a reference look-up is created, the value stored in the parameter is SheetId. However, a different display value can be selected by selecting an appropriate value for the display cell field. |
|
|
|
|
| Click on the OK button to create the reference look-up. |
|
|
|
|
| The reference parameter is highlighted as shown. |
|
|
|
|
| Add another parameter to the product model | | |
|
Use the add new parameter button to add the following parameter to the product model.
- Customizable, "Boolean" |
|
|
| | | | | |
|
|
| Save changes to the product model | | |
| Click on the save and close button to save the changes.
|
|
| | | |
|
| |
|
|
The reference look-up relationship between the category and product model is indicated as shown. |
|
|
|
Implementing a parent/child relationship
|
| Create product color model under catalog menu | | |
|
Now that we have created the product model, let's create the product colour model as the child of the product model.
Click on the new model icon. A dialog box will be displayed.
|
|
| Select the "Catalog Menu" folder, Enter "ProductColour" as the model name and then click on create model button. |
|
|
| Create parent/child reference | | |
|
Use the add new paramter button to create a new parameter and establish a parent/child relationship with Product model. Click on the add new parameter button.
|
|
Select "Reference" option. Enter "ProductCode" in the Name field, select "Product" from the dropdownlist for model and "ProductCode" from the dropdown list for display cell.
|
| | | | | | | |
|
| |
|
|
Select "Yes", which is the default vaule for the parent/child option, and then click on the OK button to create a parent/child relationship. |
|
|
|
|
|
The newly created parent/child reference is highlighted as shown.
|
|
|
|
| Add parameters to product colour model | | |
|
Use the add new parameter button to add the following parameters to the product colour model.
- Product Colour, "Text" - Attachment, "Text"
Did you know? To upload attachments, a parameter with the name "Attachment" must be created in the data model. |
|
| | |
|
|
|
The parent/child relationship between the product and product colour model is indicated as shown. |
|
|
|
|
| Create product size model | | |
|
Now that we have created the product colour model, let's create the product size model as the child of the product colour model. Click on the new model icon. |
|
|
| A dialog box will be displayed. Select the "Catalog Menu" folder, Enter "ProductSize" as the model name and then click on create model button. |
|
|
| Create parent/child reference | | |
|
Use the add new paramter button to create a new parameter and establish a parent/child relationship with product colour model. Click on the add new parameter button. |
|
|
| Select "Reference" option. Enter "ProductCode" in the Name field, select "ProductColour" from the dropdownlist for model and "ProductCode" from the dropdown list for display cell. Select "Yes", which is the default vaule for the parent/child option, and then click on the OK button to create a parent/child relationship. |
|
|
|
The newly created parent/child reference parameter is highlighted as shown.
|
|
|
|
| Add parameters to product size model | | |
|
Use the add new parameter button to add the following parameters to the product size model.
- Product Size, "Text" |
|
|
|
|
|
The parent/child relationship between the product colour and product size model is indicated as shown. |
|
|
|
|
|