easy ui tree

action JSON的值是這樣的:
[color=red]{"systemMenuTreeList[/color]":[{"attributes":null,"children":[],"iconCls":null,"id":"282","state":"open","text":"test"},{"attributes":null,"children":[{"attributes":null,"children":[{"attributes":null,"children":[{"attributes":{"menuUrl":"dd"},"children":[],"iconCls":"ico-sub_menu","id":"1","state":"open","text":"系統管理"},{"attributes":{"menuUrl":"ee"},"children":[],"iconCls":"ico-sub_menu","id":"2","state":"open","text":"模組管理"},{"attributes":{"menuUrl":"ff"},"children":[],"iconCls":"ico-sub_menu","id":"3","state":"open","text":"父菜單管理"},{"attributes":{"menuUrl":null},"children":[],"iconCls":"ico-sub_menu","id":"4","state":"open","text":"子菜單管理"},{"attributes":{"menuUrl":null},"children":[],"iconCls":"ico-sub_menu","id":"5","state":"open","text":"用戶管理"},{"attributes":{"menuUrl":null},"children":[],"iconCls":"ico-sub_menu","id":"6","state":"open","text":"用戶權限管理"}],"iconCls":"icon-save","id":"1","state":"open","text":"系統管理"}],"iconCls":"icon-save","id":"1","state":"open","text":"系統管理"}],"iconCls":"ico-systems","id":"1","state":"open","text":"系統管理"},{"attributes":null,"children":[{"attributes":null,"children":[{"attributes":null,"children":[{"attributes":{"menuUrl":"www.baidu.com"},"children":[],"iconCls":"ico-sub_menu","id":"7","state":"open","text":"測試1"},{"attributes":{"menuUrl":"www.126.com"},"children":[],"iconCls":"ico-sub_menu","id":"8","state":"open","text":"測試2"},{"attributes":{"menuUrl":"cc"},"children":[],"iconCls":"ico-sub_menu","id":"9","state":"open","text":"測試3"}],"iconCls":"icon-save","id":"2","state":"open","text":"測試程序"}],"iconCls":"icon-save","id":"2","state":"open","text":"測試"}],"iconCls":"ico-systems","id":"2","state":"open","text":"測試"}]}

然後easy ui需要的JSON數據格式是:
[{
"id":1,
"text":"Folder1",
"iconCls":"icon-save",
"children":[{
"text":"File1",
"checked":true
},{
"text":"Books",
"state":"open",
"attributes":{
"url":"/demo/book/abc",
"price":100
},
"children":[{
"text":"PhotoShop",
"checked":true
},{
"id": 8,
"text":"Sub Bookds",
"state":"closed"
}]
}]
},{
"text":"Languages",
"state":"closed",
"children":[{
"text":"Java"
},{
"text":"C#"
}]
}]


/*
* 獲取系統菜單樹JSON
*/
function getSystemMenuTree(){
//獲取系統菜單樹JSON數據
$('#menuTree').tree({
url: "../admin/systemMenuTreeJsonAction!getSystemMenuTreeJson",
loadFilter: function(data){
//alert(data.systemMenuTreeList);
return data.systemMenuTreeList[color=red];//這裏必須經過處理,不能直接返回data[/color] //return data;
} ,
formatter:function(node){
//return "<a href='#'>"+ node.text + "</a>";
return node.text;
},
onClick: function(node){
//alert($('#menuTree').tree('isLeaf',node.target));
//alert(node.attributes.menuUrl);
if($('#menuTree').tree('isLeaf',node.target)){
alert(node.attributes.menuUrl);
//window.location.href=node.attributes.menuUrl;
window.navigate(node.attributes.menuUrl);
alert(node.text); // alert node text property when clicked
}
}
});
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章