IRdsElementsSorter.Revert

Syntax

Revert();  

Description

The Revert method returns arrangement of the MDM dictionary elements in its initial state.

Example

Create a form, place the following components on it: buttons named Button1 and Button2, the RdsDictionaryBox component named RdsDictionaryBox1 and the UiRdsDictionary component that is a data source for RdsDictionaryBox1.

Class OBJ26217Form: Form
    RdsDictionaryBox1: RdsDictionaryBox;
    UiRdsDictionary1: UiRdsDictionary;
    Button1: Button;
    dictionary: IRdsDictionaryInstance;
    sorter: IRdsElementsSorter;

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    com: CustomComparer;
Begin
    com := New CustomComparer.Create;
    sorter := dictionary.Elements.CreateSorter(dictionary.Elements.Root);
    sorter.Comparer := com As IRdsElementComparer;
    sorter.Sort(True);
    RdsDictionaryBox1.RefreshElements;
End Sub Button1OnClick;

Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
    sorter.Revert();
End Sub Button2OnClick;

Sub OBJ26217FormOnShow(Sender: Object; Args: IEventArgs);
Begin
    dictionary := RdsDictionaryBox1.Source.Instance;
End Sub OBJ26217FormOnShow;

End Class OBJ26217Form;

Class CustomComparer: Object, IRdsElementComparer

Function Less(LValue: IRdsDictionaryElement; RValue: IRdsDictionaryElement): Boolean;
Var
    comp: IComparer;
Begin
    comp := comparer.StringCaseInsensitiveComparer;
    If (Comp.Compare(LValue.Name, RValue.Name) > 0Then Return True
        Else Return False;
    End If;
End Function Less;

End Class CustomComparer;

After executing the example, pressing the Button1 button creates a custom sorter of the MDM dictionary elements, pressing the Button2 button restores initial arrangement of MDM dictionary elements.

See also:

IRdsElementsSorter