Expand or collapse single node.
Use expandNode() method of zTree v3.x can trigger 'beforeExpand / onExpand' or 'beforeCollapse / onCollapse' callback function. for reduce redundant code.
Please use zTree object to executing the method.
JSON data object of the node to be expanded or collapsed
Please ensure that this data object is an internal node data object in zTree.
expandFlag = true means: expand the node.
expandFlag = false means: collapse the node.
If this parameter is omitted, then toggle expand or collapse depend this node's expanded state.
sonSign = true means: expand or collapse all of the child nodes depend the 'expandFlag' parameter.
sonSign = false means: only expand or collapse this node.
When sonSign = false and treeNode.open = expandFlag, will not trigger the callback.
If this parameter is omitted, it is same as 'sonSign = false'.
focus = true means: after expand or collapse, set the focus of this node for view.
focus = false means: after expand or coolapse, don't set the focus of this node.
If this parameter is omitted, it is same as 'focus = true'.
callbackFlag = true means: call this method, will trigger 'beforeExpand / onExpand' or 'beforeCollapse / onCollapse' callback.
callbackFlag = false means: call this method, will not trigger callback.
If this parameter is omitted, it is same as 'callbackFlag = false'
return the result of expand or collapse.
true means: expand node
false means: collapse node
null means: the node is not parent node.
var treeObj = $.fn.zTree.getZTreeObj("tree");
var nodes = treeObj.getSelectedNodes();
if (nodes.length>0) {
treeObj.expandNode(nodes[0], true, true, true);
}