comebotree树

comebotree树:

 

 

java:

@RequestMapping(value="/combobox.do")

public @ResponseBody
String combobox(String booid){

List<Map<String, Object>> list =new ArrayList<Map<String, Object>>();

List<TestModel> rs=testService.getlists(booid);

for(TestModel md:rs){

Map<String, Object> map = new HashMap<String, Object>();//定义map
map.put("id", md.getBookid());
map.put("text", md.getSummarize());


String pid=String.valueOf(md.getBookid());
int count=testService.getcount(pid);
if(count>0)
{
map.put("state", "closed");
}else{
map.put("state", "open");
}

list.add(map);

}

System.out.println(JSON.toJSONString(list));

return JSON.toJSONString(list);
}

 

 

页面:

$('#CC').combotree({
valueField:'id',
textField:'text',
editable:false,
panelHeight:'auto',
value:'',
url:'test/combobox.do',
onLoadSuccess: function (node, data) {

//异步树全部自动展开
var t = $(this);
if (data) {
$(data).each(function (index, d) {
if (this.state == 'closed') {
t.tree('expandAll');
}
});
}

},
onSelect:function(value){
console.log(value);
},

//异步树动态展开
onBeforeExpand:function(node){
console.log("---node---",node);
$('#CC').combotree("tree").tree("options").url= "test/combobox.do?booid=" + node.id;


}
});

 

posted @ 2014-12-02 10:42  江湖小谢*VIP  阅读(205)  评论(0编辑  收藏  举报