GroupKey(Element: Integer): Integer;
Element - dictionary element index.
The GroupKey method returns group key for element. The method returns 0 if the element is not a group.
Executing the example requires a form, a button named Button1 positioned on this form and the following components: UiDimension with the UiDimension1 identifier, UiRdsDictionary with the UiRdsDictionary1 identifier, Memo with the Memo1 identifier, and the DimensionTree component. UiRdsDictionary1 is used as the data source for the DimensionTree component. The repository should include MDM repository MDM_REPO that contains the dictionary named OBJ_DICTIONARY.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Metabase: IMetabase;
RdsKey: Integer;
Object: IMetabaseObjectDescriptor;
Params: IMetabaseObjectParams;
Param: IMetabaseObjectParam;
Values: IMetabaseObjectParamValues;
Dictionary: IRdsDictionaryInstance;
Dict: IRdsDictionary;
DimInstance: IDimInstance;
Elements: IDimElements;
Element: Integer;
i: Integer;
Begin
Metabase := MetabaseClass.Active;
RdsKey := Metabase.GetObjectKeyById("RDS_REPO");
Object := Metabase.ItemByIdNamespace("OBJ_DICTIONARY", RdsKey);
Object := Object.Edit;
Params := Object.Params;
Param := Params.Add;
Param.Name := "RDSDIMTYPE";
Param.Id := "RDSDIMTYPE";
Param.DataType := DbDataType.Integer;
Values := Params.CreateEmptyValues;
Values.FindById("RDSDIMTYPE").Value := 1;
Dictionary := Object.Open(Values) As IRdsDictionaryInstance;
DimInstance := Dictionary As IDimInstance;
UiDimension1.Instance := DimInstance;
Dict := Dictionary.Dictionary;
UiRdsDictionary1.Object := Dict;
UiRdsDictionary1.Open(Values);
UiRdsDictionary1.Active := True;
Memo1.Clear;
Elements := DimInstance.Elements;
For i := 0 To Elements.Count - 1 Do
Element := Elements.Elements.Element(i);
If Elements.IsGroup(Element) Then
Memo1.Lines.Add(" group: " + Elements.Name(Element));
Memo1.Lines.Add(" Group key: " + Elements.GroupKey(Element).ToString);
Else
Memo1.Lines.Add("Element: " + Elements.Name(Element));
End If;
End For;
End Sub Button1OnClick;
After executing the example the DimensionTree component shows groups and elements of the OBJ_DICTIONARY dictionary as a tree. The Memo component displays information on dictionary elements (name) and groups (name and key).
See also: