Index: Integer;
The Index property returns index of the attribute of sorting in the collection.
Executing the example requires a form with the Button1 button, the RdsDictionaryBox1 component, and the UiRdsDictionary1 component that is a data source of the RdsDictionaryBox1 component. An MDM dictionary is connected to the UiRdsDictionary1 component via the Object property. Add links to the ExstCtrls, Forms, Metabase and Rds system assemblies.
The example is a handler of the OnClick event for the button.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Dict: IRdsDictionaryInstance;
Attrs: IRdsAttributes;
SAttr: IRdsSortAttribute;
Sorter: IRdsElementsSorter;
Elems: IRdsDictionaryElements;
Begin
Dict := RdsDictionaryBox1.Source.Instance;
Elems := Dict.Elements;
Sorter := Elems.CreateSorter(Elems.Root);
Attrs := Dict.Dictionary.Attributes;
SAttr := Sorter.Attributes.Add(Attrs.FindById("Name"), True);
debug.WriteLine(SAttr.Index);
Sorter.Sort(False);
RdsDictionaryBox1.RefreshElements;
End Sub Button1OnClick;
After executing the example, clicking the Button1 button sorts by the Name attribute and displays sorting attribute index in the console window.
See also: