In this article:

General Information

Description

Opening Parametric Dictionaries

Getting Values of Specified Attributes for Selected Dictionary Elements

Getting Element Index Based on the Specified Value of Its Attribute

Working with Dictionaries in the DimensionTree/DimensionCombo Components

Article number: KB000018

General Information

Related blocks:

Description

The DimensionTree and DimensionCombo components are used to display dictionary data. The DimensionTree component displays data as a tree and the DimensionCombo component displays data as a drop-down list. The UiDimension component is used as a data source for these components.

Methods for working with dictionaries in the DimensionTree and DimensionCombo components are described below.

Opening Parametric Dictionaries

The UiMetabaseObjectParams component is used to control values of parameters of repository objects. When working with the UiDimension component, you need to configure it to a parametric dictionary. Execute the following operations:

To apply parameters while the form is working, refresh the dictionary:

UiDimension1.Active := False;
UiDimension1.Active := True;

Getting Values of Specified Attributes for Selected Dictionary Elements

There is a custom form containing the following components: Button (Button1 name), Memo (Memo1 name), DimensionTree (DimensionTree1 name) and the UiDimension component used as a data source for DimensionTree.

The example describes getting of values of the NAME attribute for dictionary elements selected in the DimensionTree1 component loaded to UiDimension. The example is executed on clicking the Button1 button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    DimInstance: IDimInstance;
    SelectedElements: IDimElementArray; //collection of selected elements
    Attribute: IDimAttributeInstance; //attribute, which value must be obtained
    ElementIndex, ElementCount: Integer;
    DimensionElement: Integer;
Begin
    DimInstance := DimensionTree1.Dimension.DimInstance;
    Attribute := DimInstance.Attributes.FindById("NAME");
    SelectedElements := DimensionTree1.Selection.SelectedElementArray(NULL);
    ElementCount := SelectedElements.Count - 1;
    For ElementIndex := 0 To ElementCount Do
        DimensionElement := SelectedElements.Element(ElementIndex);
        Memo1.Lines.Add(Attribute.Value(DimensionElement) As String);
    End For;
End Sub Button1OnClick;

After executing the example value of the NAME attribute for each of the selected elements is added to the Memo1 component.

Getting Element Index Based on the Specified Value of Its Attribute

There is a custom form containing the following components: Button (Button1 name), Memo (Memo1 name), DimensionTree (DimensionTree1 name) and the UiDimension component used as a data source for DimensionTree.

The example describes getting of index of the dictionary element displayed in the DimensionTree1 component. Element index is to be obtained based on the value of the specified attribute. The example is executed on clicking the Button1 button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    DimInstance: IDimInstance;
    Attributes: IDimAttributesInstance;
    DimensionElement, //index of found dictionary element
    AtIndex: Integer; //index of attribute, by which search is executed
    AtValue: Variant; //attribute value, by which search is executed
Begin
    AtIndex := 1;
    AtValue := "Fifth element";
    DimInstance := DimensionTree1.Dimension.DimInstance;
    Attributes := DimInstance.Attributes;
    DimensionElement := Attributes.Item(AtIndex).LookupValue(AtValue);
    Memo1.Lines.Add(DimensionElement.ToString);
End Sub Button1OnClick;

After executing the example the Memo1 component contains index of the element which has the value of the attribute with index 1 equal to "Fifth element".

One can use FindById("NAME") instead of Item(AtIndex) to search for the dictionary element index by the specified attribute with the NAME identifier.

See also:

Developers Knowledge Base

DimensionTree | DimensionCombo | UiDimension | UiMetabaseObjectParams