IDimInstance.NewElementsOrderSetup

Fore Syntax

NewElementsOrderSetup: IDimElementsOrderSetup;

Fore.NET Syntax

NewElementsOrderSetup(): Prognoz.Platform.Interop.Dimensions.IDimElementsOrderSetup;

Description

The NewElementsOrderSetup method returns settings of dictionary elements custom sorting.

Fore Example

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(NullAs 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(0Then
        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.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dimensions;

Public Shared Sub Main(Params: StartParams);
Var 
    MB: IMetabase;
    OrderSetup: IDimElementsOrderSetup;
    Attribute : IDimAttribute;
    AttrInst: IDimAttributeInstance;
    Iterator: IDimTreeIterator;
    DimInst: IDimInstance;
Begin
    MB := Params.Metabase;
    DimInst := MB.ItemById["DIM"].Open(NullAs IDimInstance;
    OrderSetup := DimInst.NewElementsOrderSetup();
    AttrInst := DimInst.Attributes.Item[1];
    Attribute := AttrInst.Attribute;
    // Add attribute to the sorting list
    OrderSetup.Add(Attribute, False);
    System.Diagnostics.Debug.WriteLine("Number of sorting attributes: " + OrderSetup.Count);
    System.Diagnostics.Debug.WriteLine("Sorting by attribute " + Attribute.Name + ", attribute key: " 
        + OrderSetup.AttributeKey(0));
    // Get iterator for a tree built with taking sorting into account
    Iterator := DimInst.ElementsByOrder[OrderSetup];
    // Determine sorting order
    If OrderSetup.ReverseOrder[0Then
        System.Diagnostics.Debug.WriteLine("Descending sorting");
        Else
            System.Diagnostics.Debug.WriteLine("Ascending sorting");
    End If;
    // Display dictionary elements taking sorting into account
    While Iterator.HasNext() >= 0 Do
        System.Diagnostics.Debug.WriteLine(DimInst.Elements.AttributeValueO[Iterator.GetElement(), AttrInst]);
    // If element has owner, display owner index
        If Iterator.GetParent() >= 0 Then
            System.Diagnostics.Debug.WriteLine("Element owner index: " + Iterator.GetParent());
        End If;
    End While;
    // Move to the iterator beginning
    Iterator.ResetIterator();
End Sub;

See also:

IDimInstance