Function(targetNode, treeNode, moveType, isSilent)zTreeObj.moveNode

Overview[ depends on jquery.ztree.exedit js ]

Move the node

Please use zTree object to executing the method.

Function Parameter Descriptions

targetNodeJSON

JSON data object of the node to be target.

If move the node to root node, please set the 'targetNode' to null.

Please ensure that this data object is an internal node data object in zTree.

treeNodeJSON

JSON data object of the node to be moved.

Please ensure that this data object is an internal node data object in zTree.

moveTypeString

Moved to the target node's relative position.

"inner" means: to be taregetNode's child node.

"prev" means: to be taregetNode's previous sibling node.

"next" means: to be taregetNode's next sibling node.

isSilentBoolean

After move the node, whether to automatically expand its parent node.

isSilent = true means: don't expand its parent node.

isSilent = false or omit this parameter means: expand its parent node.

Return JSON

return the node which be moved, it is same as the 'treeNode' parameter.

Return null means: move node has failed. The cause:
 1. the targetNode is the treeNode's parent node, and moveType = "inner"
 2. the targetNode is the treeNode's child node.

Examples of function

1. Move the second root node to the first root node's child node.

var treeObj = $.fn.zTree.getZTreeObj("tree");
var nodes = treeObj.getNodes();
treeObj.moveNode(nodes[0], nodes[1], "inner");

2. Move the second root node to the first root node's previous sibling node.

var treeObj = $.fn.zTree.getZTreeObj("tree");
var nodes = treeObj.getNodes();
treeObj.moveNode(nodes[0], nodes[1], "prev");