HierarchyInstance: IDimHierarchyInstance;
The HierarchyInstance property determines alternative dictionary hierarchy.
To execute the example, place on form:
The Button component with the Button1 identifier.
The DimensionTree component with the DimensionTree1 identifiers.
The DimensionTree component with the DimensionTree2 identifiers.
The UiDimension component with the UiDimensionTree1 identifiers.
The UiDimension component with the UiDimensionTree2 identifiers.
The Memo component with the Memo1 identifier.
Determine:
Dictionary with the DIC identifier as data source for the components with the UiDimension1 and UiDimension2 identifier.
Component with the UiDimension1 identifier as data source for component with the DimensionTree1 identifier.
Component with the UiDimension2 identifier as data source for component with the DimensionTree2 identifier.
Add links to the Dimensions, ExtCtrls, Forms, Metabase system assemblies.
After the example is running:
Create a selection by which alternative hierarchy will be created dynamically. To do it, determine elements in the component with the DimensionTree1 identifier.
Determine elements in the component with the DimensionTree2 identifier to create additional hierarchy elementswhich were not included into selection.
The example is a handler of the OnClick event for the Button1 component.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Creator: IDimHierarchyCreator;
Begin
// Create a dynamically alternative hierarchy
Creator := New DimHierarchyCreator.Create;
// Get selection with elements, by which alternative hierarchy is created
Creator.Selection := DimensionTree1.Selection;
// Get selection with additional elements
Creator.AdditionalElements:=DimensionTree2.Selection;
// Set root element
Creator.RootElement:= True;
Creator.RootElementName:="Root element";
//Get alternative hierarchy
DimensionTree2.Selection.Hierarchy := Creator.HierarchyInstance;
//Display names of grouping elements
memo1.Lines.Add("Grouping elements:"+Creator.HierarchyInstance.GroupingElements.ToString("NAME",";"));
End Sub Button1OnClick;
After executing the example the component with the DimensionTree2 identifier displays the created dynamically alternative hierarchy with the Root Element root element, and the component with the Memo1 identifier contains grouping element name.
See also: