问题
I am using jstree and jstree grid for contructing my tree structure. Can I split the constructed jstree into 2 parts?
回答1:
You can split it with code as below. Check demo: Fiddle
$("#tree1")
.on("select_node.jstree", function(e, data) {
// destroy second tree and remove DOM elements
if ($("#tree2").find('ul').length > 0) {
$("#tree2").jstree('destroy').empty();
}
// get json format for branch to move selected node/branch from first tree
var json = data.instance.get_json(data.node);
// init second tree with new data
$("#tree2").jstree({
"core": {
"data": json
}
});
// remove selected node/branch from the first tree
$("#tree1").jstree('delete_node', [data.node.id]);
$("#" + data.node.id).remove();
})
.jstree({
"core": {
"data": data1
}
})
来源:https://stackoverflow.com/questions/34940429/how-do-i-split-constructed-jstree-into-2-parts