moveItem(key: Number, targetKey: Number, relation: PP.Mb.TreeRelation);
key. Key of the element to move. If this parameter is not defined the method moves all selected elements.
targetKey. Key of the element relative to which another element moves.
relation. Elements relation.
The moveItem method moves element to a specified position relative to another element.
To execute this example, the page must contain the DictionaryBox component named dictionaryBox (see Example of creating the DictionaryBox component ). Manually add two elements named Minute and Hour to the tree:
Get array of children for tree root node. Place the element with the index 4 before the element with the index 3:
// Obtain dictionary data area var area = dictionaryBox.getDataArea(); // Obtain dictionary element tree var tree = area.getActiveDictTree(); // Obtain child array of tree root elements var items = tree._Source.getChildEls(); // Place element with 4 index before element with 3 index tree.moveItem(items[4].getKey(), items[3].getKey(), PP.Mb.TreeRelation.PrevSibling);
As the result the element is moved:
Copy element with the index 4 to clipboard and paste it in the position of element with the index 3 as its child:
// Copy element with 4 index to the clipboard tree.pushToClipboard(PP.Rds.Ui.TreeOperations.CopyElements, [items[4].getKey()]); // Insert a value from the clipboard to the element with specified key tree.pasteClipboard(items[3].getKey());
As the result the element with the index 4 is copied to specified position:
Remove element with the index 3
tree.removeItem([items[3].getKey()], false);
As the result the element with the index 3 is removed:
See also: