Hi!
I need a tree to exlored N times, but I read the Examples “Preload children”, it’s need to know hao many child levels the parent node have. When there’s 5 levels tree ,there must have 5 nested inside。
Now I had a tree Examples on JSP ,devloped by ztree, the data in each layer comes from different tables,and I had usefull backend method. The method accept the node and return the children node list.
the tree looks like this:
My code
<f7-treeview>
<f7-treeview-item
id="tree"
:toggle="true"
:selectable="true" :loadChildren="true"
v-for="item in treeData"
:selected="selectedItem === item"
@treeview:loadchildren="(event, done) => getChildNode(item, done)"
:label="item.name">
<!-- I do not want write this child one in one -->
<f7-treeview-item
id="tree"
item-toggle
:selected="selectedItem === item1"
v-for="item1 in item.nodeList"
@treeview:loadchildren="(event, done) => getChildNode(item1, done)"
:label="item1.name"></f7-treeview-item>
</f7-treeview-item>
</f7-treeview>
js code:
getChildNode( item,done){
debugger
let _self = this
let node=item
_self.request.get(
{
url:'tzTree/tzTreeSelect?codeType='+node.codeType+'&id='+node.id+'&name='+node.name+'&dvType='+node.dvType+'&deptId='+node.deptId,
}
).then(function (response) {//get children
debugger
item.nodeList=response.data.obj// how put children to parent?
done()
})
},
How can I push children nodes list to the parent node,and set every child has the same onclick event js with the child node as params。
Thanks