Function(treeNode, expandFlag, sonSign, focus, callbackFlag)zTreeObj.expandNode

Overview[ depends on jquery.ztree.core js ]

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.

Function Parameter Descriptions

treeNodeJSON

JSON data object of the node which will be expanded or collapsed

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

expandFlagBoolean

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.

sonSignBoolean

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'.

focusBoolean

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'.

callbackFlagBoolean

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 Boolean

return the result of expand or collapse.

true means: expand node

false means: collapse node

null means: the node is not parent node.

Examples of function

1. Expand the first selected node. (and expand this node's child nodes)

var treeObj = $.fn.zTree.getZTreeObj("tree");
var nodes = treeObj.getSelectedNodes();
if (nodes.length>0) {
	treeObj.expandNode(nodes[0], true, true, true);
}