IRdsDictionaryElement.MoveTo

Syntax

MoveTo(TargetKey: Integer; MoveType: RdsMoveType);

Parameters

TargetKey. Key of an element, relative to which move is executed.

MoveType. Position in that a current element is moved relatively to the TargetKey element.

Description

The MoveTo method moves an element of the MDM dictionary to the position specified relatively to an element with given key.

Comments

An element may be moved relatively to a root element of a dictionary. For this, it is necessary to pass value -2 (a dictionary root element) as the TargetKey parameter. An element can be moved to any position except for RdsMoveType.Before (up to a specified element).

Example

Executing the example requires an MDM repository with the RDS_REPO identifier that contains a dictionary with the OBJ_DICT identifier. It is also necessary to add links to the Metabase, Rds system assemblies.

    Sub UserProc;
    Var
        MB: IMetabase;
        RdsDescr: IMetabaseObjectDescriptor;
        Dict: IRdsDictionary;
        DictInst: IRdsDictionaryInstance;
        Elements: IRdsDictionaryElements;
        MoveElem: IRdsDictionaryElement;
        ElemKey: Integer;
    Begin
        MB := MetabaseClass.Active;
        RdsDescr := MB.ItemById("RDS_REPO");
        Dict := MB.ItemByIdNamespace("OBJ_DICT", RdsDescr.Key).Bind As IRdsDictionary;
        DictInst := Dict.Open(Null);
        Elements := DictInst.Elements;
    // Receive the first element of a dictionary   
        MoveElem := Elements.Item(1);
    // Receive key of the last element of a dictionary      
        ElemKey := Elements.Child(-2, Elements.ChildrenCount(-2) - 1);
    // Move element 
        MoveElem.MoveTo(ElemKey, RdsMoveType.Before);
    End Sub UserProc;

After executing the example the first element of a dictionary is moved before the last element of a dictionary.

See also:

IRdsDictionaryElement