转载出处 :http://www.cnblogs.com/wangjunwei/p/4932366.html
$('#areaName').combotree({ url: '../Ajax/Common.ashx?Method=GetCombotreeData', multiple: true, checkbox: true, isShowPic: false, onCheck: function (node, checked) { // MainJs.RemoveNodeAll('areaName'); }, onLoadSuccess: function (node, data) { var rootNode = data[0];//第一个节点 if (rootNode) { var t = $('#areaName').combotree('tree'); // 获取树对象 var node1=t.tree('find', rootNode.id); t.tree("uncheck", node1.target); //取消所有的选中 } } });
默认选中根节点的方法
onLoadSuccess: function (node, data) { var t = $('#WAY_JY').combotree('tree'); // 获取树对象 var rootNode = t.tree('getRoot');//基础节点 //var node1 = t.tree('find', rootNode.id); t.tree("uncheck", rootNode.target); //取消所有的选中 }
json格式
[ { "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": "index.html" }, { "id": 14, "text": "about.html" }, { "id": 15, "text": "welcome.html" } ] } ]
清空控件的值:
$("#type").combotree('clear');//清空控件的值
---->