Examples are as follows:
<ul ></ul>
$('#regionTree').tree({ cascadeCheck: false, //onlyLeafCheck: true, checkbox: true, data: [{ "id": 1, "text": "My Documents", "children": [{ "id": 11, "text": "Photos", "state": "closed", "children": [{ "id": 111, "text": "Friend" }, { "id": 112, "text": "Wife" }, { "id": 113, "text": "Company" }] }, { "id": 12, "text": "Program Files", "children": [{ "id": 121, "text": "Intel" }, { "id": 122, "text": "Java", "attributes": { "p1": "Custom Attribute1", "p2": "Custom Attribute2" } }, { "id": 123, "text": "Microsoft Office" }, { "id": 124, "text": "Games", "checked": true }] }, { "id": 13, "text": "" }, { "id": 14, "text": "" }, { "id": 15, "text": "" }] }] , width: 160, height: 32, panelHeight: 400, onSelect: function (node) { var cknodes = $('#regionTree').tree("getChecked"); for (var i = 0; i < ; i++) { if (cknodes[i].id != ) { $('#regionTree').tree("uncheck", cknodes[i].target); } } if () { $('#regionTree').tree('uncheck', ); } else { $('#regionTree').tree('check', ); } }, onLoadSuccess: function (node, data) { $(this).find('-checkbox').unbind().click(function () { $('#regionTree').tree('select', $(this).parent()); return false; }); } })
Key Code:
onSelect: function (node) { var cknodes = $('#regionTree').tree("getChecked"); for (var i = 0; i < ; i++) { if (cknodes[i].id != ) { $('#regionTree').tree("uncheck", cknodes[i].target); } } if () { $('#regionTree').tree('uncheck', ); } else { $('#regionTree').tree('check', ); } }, onLoadSuccess: function (node, data) { $(this).find('-checkbox').unbind().click(function () { $('#regionTree').tree('select', $(this).parent()); return false; }); }
The above simple example of easyi tree with checkbox to implement single choice is all the content I share with you. I hope you can give you a reference and I hope you can support me more.