Hello Sir,
I am using treeview with context menu. When I add new node or rename node an once I click on save button the JSON has to be save in database. Next time I will take saved JSON from database and able to draw tree with saved content.
Thanks
Yogesh
save(e) {
console.log(this.treeInstance.getTreeData());
} |
Hello Team,
Thanks for response. The solution works fine.
Now I want to get selected node name just like node id. Is there any possible way?
Thanks,
Yogesh Patil
var selectedNode = this.treeInstance.selectedNodes;
console.log(this.treeInstance.getTreeData());
console.log(this.treeInstance.getTreeData(selectedNode[0]));
console.log(this.treeInstance.getNode(selectedNode[0])); |
Hello Keerthana R.
Thanks for the reply.
I have already used getTreeData function to get name of selected node by passing id. And it's working fine.
Thanks once again for support.
Thanks
Yogesh
Hello Keerthana R,
Everything is working fine now. Thanks for support.
I have one more requirement, while removing any node if sub nodes are present then, it should not remove the node and give popup regarding same.
Thanks
Yogesh P.
this.treeInstance.getNode(targetNodeId).hasChildren ? alert('Remove is restricted for parent nodes') : this.treeInstance.removeNodes([targetNodeId]); |
Hello Keerthana R.
Thanks for reply. The solution works fin for me.
I have two more requirements:
1) I have to restrict nodes to be added when level of node reached to 10.
2) Once removing node I have to update same to different table.
Thanks,
Yogesh
if (args.item.text == 'Add New Item') {
if ((targetNode.subChild && targetNode.subChild.length < 10) || !targetNode.subChild ) {
//check required condition here before adding nodes.
let nodeId: string = 'tree_' + this.index;
let item: { [key: string]: Object } = {
id: nodeId,
name: 'New Folder',
};
this.treeInstance.addNodes([item], targetNodeId, null);
this.index++;
this.hierarchicalData.push(item);
this.treeInstance.beginEdit(nodeId);
}
} |