3.9.1.2. DynamicAttributesPanel
If an entity implements com.haulmont.cuba.core.entity.Categorized interface, you can use DynamicAttributesPanel component for displaying dynamic attributes of this entity. This component allows a user to select a category for the particular entity instance and specify values of dynamic attributes of this category.
In order to use the DynamicAttributesPanel component in an edit screen, do the following:
-
Include the
categoryattribute to the view of your categorized entity:<view entity="ref_Car" name="car-view" extends="_local"> <property name="category" view="_minimal"/> </view> -
Declare an InstanceContainer in the
datasection:<data> <instance id="carDc" class="com.company.ref.entity.Car" view="car-view"> <loader dynamicAttributes="true"/> </instance> </data>Set the
dynamicAttributesparameter of the loader totrueto load the entity’s dynamic attributes. Dynamic attributes are not loaded by default. -
Now, the
dynamicAttributesPanelvisual component may be included in the XML-descriptor of the screen:<dynamicAttributesPanel dataContainer="carDc" cols="2" rows="2" width="AUTO"/>You can specify the number of columns to display dynamic attributes using the
colsparameter. Or you can use therowsparameter to specify the number of rows (in this case, the number of columns will be calculated automatically). By default, all attributes will be displayed in one column.On the Attributes Location tab of the category editor, you can more flexibly customize the position of the dynamic attributes. In this case, the values of the
colsandrowsparameters will be ignored.