The official examples are simple examples of how to turn JSON data into a tree.
This example can meet our general needs. Many times we need to use a tree with a checkbox.
In fact, adding a checkbox is simple, just add the checked entry (for True/false) to the returned JSON data. To achieve what we want to select the parent node of the checkbox, the automatic selection of the neutron node is also very simple, just add the following section of code can be. View plain Copy to clipboard print? Tree.on (' Checkchange ', function (node, checked) { node.expand (); node.attributes.checked = checked; node.eachchild (function (child) { child.ui.togglecheck (checked); child.attributes.checked = checked; child.fireevent (' Checkchange ', child, checked); }); }, tree);
Tree.on (' Checkchange ', Function (node, checked) {
node.expand ();
node.attributes.checked = checked;
Node.eachchild (function (child) {
Child.ui.toggleCheck (checked);
child.attributes.checked = checked;
Child.fireevent (' Checkchange ', child, checked);
});
Demo (Demo) address at the end of the article.
The effect chart is as follows:
Source code includes 0005_checkbox_reorder.html,0005_checkbox_reorder_tree.php.
0005_checkbox_reorder.html View plain Copy to clipboard print?
0005_checkbox_reorder_tree.jsp [{"CLS": "Folder", "id": "leaf": False,checked:false, "Children": [{"CLS": "File", " ID ": One," leaf ": True,checked:false," children ": null," text ":" S600 "},{" CLS ":" File "," id ":" Leaf ": true,checked: False, "Children": null, "text": "SLK200"}], "text": "Benz"}]