This article mainly introduces ExtJs's dynamic generation of treepanel Json format. For more information, see add the "checked" attribute to the node to automatically generate the checkbox.
Obtain the selected node
Var nodeArray = ""; var nodesObj = mytree. getChecked (); var I; var length = nodesObj. length; for (I = 0; I <length; I ++) {nodeArray + = nodesObj [I]. id + ','; // You can select multiple options. If multiple selections are not allowed, directly nodesObj [I]. id} nodeArray = nodeArray. substring (0, nodeArray. length-1 );
The Json format is as follows:
[{"text": "To Do", "cls": "folder","expanded": true,"children": [{"text": "Go jogging","leaf": true,"checked": true},{"text": "Take a nap","leaf": true,"checked": false},{"text": "Climb Everest","leaf": true,"checked": false}]},{"text": "Grocery List","cls": "folder","children": [{"text": "Bananas","leaf": true,"checked": false},{"text": "Milk","leaf": true,"checked": false},{"text": "Cereal","leaf": true,"checked": false},{"text": "Energy foods","cls": "folder","children": [{"text": "Coffee","leaf": true,"checked": false},{"text": "Red Bull","leaf": true,"checked": false}]}]},{"text": "Remodel Project", "cls": "folder","children": [{"text": "Finish the budget","leaf": true,"checked": false},{"text": "Call contractors","leaf": true,"checked": false},{"text": "Choose design","leaf": true,"checked": false}]}]
The above is all the content of this article. I hope you will like it.