Save;
The Save method saves results of dictionary elements sorting in the database.
Create a form, place the following components on it: a button named Button1, 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);
sorter.Save;
RdsDictionaryBox1.RefreshElements;
End Sub Button1OnClick;
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) > 0) Then Return True
Else Return False;
End If;
End Function Less;
End Class CustomComparer;
After executing the example, pressing the button creates a custom sorter of the MDM dictionary elements and saves the result of dictionary element sorting in the database.
See also: