Combo (value of widget)
The default widget when creating this kind of relationships is a select box that allows the user to select among the options of a drop down list. But when the options dataset increases in size, this widget is not very handy.
The combo widget displays a standard text box field that allows the user to type in it and suggests records that comply with the search criteria defined for the widget, such as "starts with". The widget can be triggered when typing in the text field or by double clicking on it. When a value is typed, the widget displays a set of results from which the user may select one.
You will need to specify a value for the comboproperty attribute of the property. This value is the property on the related entity on which the suggested results will be filtered. You will also need to create a filter for that same property on the related entity. Make sure to use the same name for the filter as you used for the comboproperty attribute.
In the following example, a Company entity defines a "responsible" property of entity type "Seller". It specifies the use of the combo widget by setting the widget attribute with the "combo" value.
The comboproperty is set to "lastName" so that end-users will restrict the dataset suggested for the "Responsible" property by typing the Seller's last name.
Notice the filter created for the lastName property in the Seller entity. The name of the filter is "lastName", just like the property it is used on and the value for the comboproperty attribute in the responsible property of the Company entity. It is important to use the same name for this three values.
Note too how the widget displays the properties of the Seller entity. The property lastName is shown as the main data for each option as it is the one defined as comboproperty. The firstName and lastName are second because they are defined as display primary properties. At last, the active property is shown as it is defined as display secondary.
<entity label="Company" menu="Company" name="Company"> <property name="name" label="Name" display="primary" required="required" /> <property name="address" label="Address" type="text" /> <property name="active" label="Active" type="boolean" /> <property name="logo" label="Logo" type="image" /> <property label="Responsible" name="responsible" entity="Seller" widget="combo" comboproperty="lastName"/> </entity> <entity label="Seller" menu="Sellers" name="Seller"> <property display="primary" label="Name" name="name" required="required" /> <property display="primary" label="Last Name" name="lastName" required="required" /> <property display="secondary" label="Active" name="active" type="boolean" /> <filter display="primary" flag="like" label="Last Name" name="lastName" property="lastName" /> </entity>
- To show the list:
- Double-Click on the combo text input
- Arrow-Down on the combo text input
- To close the list:
- Escape on the combo text input
- Tab on the combo text input
- To navigate in the list, Arrow-Down and Arrow-Up, or Click
- To select an element:
- Click on it,
- Navigate to it with the arrows, and press TAB or ENTER