LevelNumber: Integer;
The LevelNumber property determines level index of dictionary for which elements grouping is enabled.
By default the property is set to -1, all dictionary elements are grouped.
If level is set, then elements of only this level are grouped. Elements of superior levels create parent elements with saving the whole hierarchy. Child elements saves the hierarchy towards elements of the specified level.
Executing the example requires a form in repository. The forms contains two UiDimension elements and two DimensionTree elements. The UiDimension components are connected as data sources to the DimensionTree components. Repository dictionary is connected to the UiDimension first component. The form also contains a button named Button1. The dictionary in its structure has several elements levels and attribute with the GROUP identifier.
Add a link to the Dimensions system assembly.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Dim: IDimInstance;
Sel: IDimSelection;
Creator: IDimHierarchyCreator;
HieInst: IDimHierarchyInstance;
Keys: Array Of integer;
Begin
Dim := UiDimension1.DimInstance;
Sel := UiDimension1.Selection;
Sel.SelectAll;
// Create an alternative hierarchy and set up its properties
Creator := New DimHierarchyCreator.Create;
Creator.Selection := Sel;
Keys := New Integer[1];
Keys[0] := Dim.Attributes.FindById("GROUP").Attribute.Key;
Creator.Attributes := Keys;
Creator.LevelNumber := 1;
HieInst := Creator.HierarchyInstance;
// Connect dictionary to the second component and set alternative hierarchy
UiDimension2.Instance := Dim;
UiDimension2.Selection.Hierarchy := HieInst;
End Sub Button1OnClick;
Clicking the button based on dictionary elements connected to the UiDimension1 component creates alternative hierarchy. Second level elements are grouped by specified attribute values. After that dictionary will be connected to the UiDimension2 component and created alternative hierarchy will be set for it.
See also: