NewElementsOrderSetup: IDimElementsOrderSetup;
The NewElementsOrderSetup method returns settings of dictionary elements custom sorting.
Executing the example requires that repository contains MDM table dictionary with the DIM identifier.
Add links to the Dimensions and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
OrderSetup: IDimElementsOrderSetup;
Attribute : IDimAttribute;
AttrInst: IDimAttributeInstance;
Iterator: IDimTreeIterator;
DimInst: IDimInstance;
Begin
MB := MetabaseClass.Active;
DimInst := MB.ItemById("DIM").Open(Null) As IDimInstance;
OrderSetup := DimInst.NewElementsOrderSetup;
AttrInst := DimInst.Attributes.Item(1);
Attribute := AttrInst.Attribute;
// Add attribute to the sorting list
OrderSetup.Add(Attribute, False);
Debug.WriteLine("Number of sorting attributes: " + OrderSetup.Count.ToString);
Debug.WriteLine("Sorting by attribute " + Attribute.Name + ", attribute key: "
+ OrderSetup.AttributeKey(0).ToString);
// Get iterator for a tree built with taking sorting into account
Iterator := DimInst.ElementsByOrder(OrderSetup);
// Determine sorting order
If OrderSetup.ReverseOrder(0) Then
Debug.WriteLine("Sort descending");
Else
Debug.WriteLine("Sort ascending");
End If;
// Display dictionary elements taking sorting into account
While Iterator.HasNext >= 0 Do
Debug.WriteLine(DimInst.Elements.AttributeValueO(Iterator.GetElement, AttrInst));
// If element has owner, display owner index
If Iterator.GetParent >= 0 Then
Debug.WriteLine("Element owner index: " + Iterator.GetParent.ToString);
End If;
End While;
// Move to the iterator beginning
Iterator.ResetIterator;
End Sub UserProc;
After executing the example dictionary elements sorting will be set up, after it iterator will be obtained for built tree. The console displays information about sorting parameters and sorted dictionary elements.
See also: