HierarchyInstance: IDimHierarchyInstance;
HierarchyInstance: Prognoz.Platform.Interop.Dimensions.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 (for Fore.NET: the TextBox component with the textBox1 identifier).
For Fore.NET instead of the Fore components use their analogs.
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
// Dynamically create alternative hierarchy
Creator := New DimHierarchyCreator.Create;
// Get selection with elements by which alternative hierarchy is generated
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 name of grouping elements
memo1.Lines.Add("Grouping elements:"+Creator.HierarchyInstance.GroupingElements.ToString("NAME",";"));
End Sub Button1OnClick;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ExtCtrls;
Imports Prognoz.Platform.Interop.Forms;
Imports Prognoz.Platform.Interop.Metabase;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
Creator: IDimHierarchyCreator;
Begin
// Dynamically create alternative hierarchy
Creator := New DimHierarchyCreator.Create();
// Get selection with elements by which alternative hierarchy is generated
Creator.Selection := dimensionTreeNet1.Selection;
// Get selection with additional elements
Creator.AdditionalElements:=dimensionTreeNet2.Selection;
// Set root element
Creator.RootElement:= True;
Creator.RootElementName:="Root element";
//Get alternative hierarchy
dimensionTreeNet2.Selection.Hierarchy := Creator.HierarchyInstance;
//Display name of grouping elements
ElemList := New List < string > ();
ElemList.Add("Grouping elements:"+Creator.HierarchyInstance.GroupingElements.ToString("NAME",";", False));
textBox1.Lines := ElemList.ToArray();
End Sub;
As a result of example execution the component with the DimensionTree2 identifier displays dynamically created alternative hierarchy with the Root Element root element, and the component with the memo 1 identifier (for Fore.NET: with the textBox1 identifier) displays grouping element name.
See also: