Attributes: Array;
Attributes: System.Array;
The Attributes property determines array of element attributes by which grouping is created.
Executing the example required that repository contains dictionary with the DIC identifier.
Add links to the Dimensions, Metabase system assemblies.
Sub Main;
Var
mb:IMetabase;
diminst:IDimInstance;
sel,sel_gr:IDimSelection;
creator: IDimHierarchyCreator;
ar: Array Of integer;
h_inst:IDimHierarchyInstance;
Begin
// Get repository
mb:=metabaseclass.Active;
// Open dictionary
diminst:=mb.ItemById("DIC").Open(Null) As IDimInstance;
// Get selection
sel:=diminst.CreateSelection;
sel.SelectElement(1, False);
sel.SelectElement(2, False);
// Display selected elements
debug.WriteLine(sel.ToString);
// Dynamically create alternative hierarchy
creator := New DimHierarchyCreator.Create;
// Create array where place key of attributes by which grouping is executed
ar:= New integer[1];
ar[0]:=1;
creator.Selection := sel;
// Send attribute by which grouping is executed
creator.Attributes:=ar;
// Get grouping dimension
h_inst:=creator.HierarchyInstance;
sel_gr:=h_inst.Source.CreateSelection;
sel_gr.SelectAll;
// Display all elements of grouping hierarchy
debug.WriteLine(sel_gr.ToString);
End Sub Main;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
mb:IMetabase;
diminst:IDimInstance;
sel,sel_gr:IDimSelection;
creator: IDimHierarchyCreator;
ar: Array Of integer;
h_inst:IDimHierarchyInstance;
Begin
// Get repository
mb:=Params.Metabase;
// Open dictionary
diminst:=mb.ItemById["DIC"].Open(Null) As IDimInstance;
// Get selection
sel:=diminst.CreateSelection();
sel.SelectElement(1, False);
sel.SelectElement(2, False);
// Display selected elements
System.Diagnostics.Debug.WriteLine(sel.ToString("NAME", " , ", False));
// Dynamically create alternative hierarchy
creator := New DimHierarchyCreator.Create();
// Create array where place keys of attributes by which grouping is executed
ar:= New integer[1];
ar[0]:=1;
creator.Selection := sel;
// Send attributes by which grouping is executed
creator.Attributes:=ar;
// Get grouping dimension
h_inst:=creator.HierarchyInstance;
sel_gr:=h_inst.Source.CreateSelection();
sel_gr.SelectAll();
// Display all elements of grouping hierarchy
System.Diagnostics.Debug.WriteLine(sel_gr.ToString("NAME", " , ", False));
End Sub;
After executing the example, the console displays all elements of alternative hierarchy with value of the attribute by which grouping is executed.
See also: