IPrxTableIslandLayout.Sort

Syntax

Sort: IPrxTableIslandSort;

Description

The Sort property returns filtering condition for relational data area.

Comments

To determine whether relational data area rows are filtered, use the IPrxTableIslandLayout.FilterEnabled property.

Example

Executing the example requires a regular report with the REGULAR_REPORT identifier. A relational data area is placed on the report sheet.

Add links to the Metabase, Report system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Report: IPrxReport; 
    TabIs : IPrxTableIslands;
    TI : IPrxTableIsland;
    Layout : IPrxTableIslandLayout;
    Sort, Parent: IPrxTableIslandSort;
    SortItem: IPrxTableIslandSortItem;
    i, Index: Integer;
    FieldName: String;
    IsEnabled, Descending, InGroups, FilterEnabled: Boolean;
Begin
    MB := MetabaseClass.Active;
    Report := MB.ItemById("REGULAR_REPORT").Edit As IPrxReport;
    TabIs := Report.TableIslands;
    TI := TabIs.Item(0);
    Layout := TI.Layout;
    Sort := Layout.Sort;
    Sort.Enabled := TriState.Undefined; 
    Debug.WriteLine("=== Sorting conditions KIND: ===");
    If Sort.IsEnabled = True Then
        Debug.WriteLine("   Sorting is enabled. Reset its parameters");
        Else Debug.WriteLine("   Sorting is disabled. Reset its parameters");
    End If;
    Debug.WriteLine("=== Sorting conditions by fields: ===");
    For i := 0 To Sort.Count - 1 Do
        SortItem := Sort.Item(i);
        // Enable sorting by fields:
        If (i Mod 2<>0Then
            SortItem.Enabled := TriState.OnOption;
            Else SortItem.Enabled := TriState.OffOption;
        End If;
        // Enable the Descending Sorting option:
        If (i Div 2=1Then
            SortItem.Descending := True;
            Else SortItem.Descending := False;
        End If;
        // Move conditions in the required execution order:
        Sort.Item(Sort.Count - 1).MoveToPosition(Sort.Count - 2);
        Sort.Item(0).MoveLast;
        // Display sorting setup results in the console window:
        FieldName := SortItem.LayoutCell.Field.FieldName;
        Debug.WriteLine((i+1).ToString + ". Field name: " + FieldName);
        Index := SortItem.Index;
        Debug.WriteLine("   Sorting condition index: " + Index.ToString);
        IsEnabled := SortItem.IsEnabled;
        If IsEnabled = True Then
            Debug.WriteLine("   Sorting is enabled");
            Else Debug.WriteLine("   Sorting is disabled");
        End If;
        Descending := SortItem.Descending;
        If Descending = True Then
            Debug.WriteLine("   Descending sorting is enabled");
            Else Debug.WriteLine("   Descending sorting is disabled");
        End If;
        InGroups := SortItem.InGroups;
        If InGroups = True Then
            Debug.WriteLine("   Sorting within groups is enabled");
            Else Debug.WriteLine("   Sorting within groups is disabled");
        End If;
    End For;
    // Disable sorting for the field with the 1 index:
    Sort.Remove(1);
    // Remove all sorting conditions from collection:
    Sort.Clear;
    Debug.WriteLine("=== Check if filtering for KIND is enabled ===");
    Parent := SortItem.Parent;
    FilterEnabled := Parent.Parent.FilterEnabled;
    If FilterEnabled = True Then
        Debug.WriteLine("   Filtering is enabled");
        Else 
            Debug.WriteLine("   Filtering is disabled");
    End If;
    (Report As IMetabaseObject).Save;
End Sub UserProc;

After executing the example it is checked if relational data area sorting is enabled. According to check results, sorting by separate fields of relational data area is reset or set up. Settings are displayed in the console window, after which all sorting conditions are removed.

See also:

IPrxTableIslandLayout