treepanel动态加载数据实现代码

时间:2021-05-26

复制代码 代码如下:
var tree = new Ext.tree.TreePanel({
region:'west',
title:'站点树:',
width:200,
minSize:150,
maxSize:200,
iconCls:'ux-auth-menu-header-icon',
split:true,
autoScroll:true,
autoHeight:false,
collapsible:true,
rootVisable:false, //不显示根节点
root:new Ext.tree.TreeNode({
id:'root',
text:'分所',
draggable:false,
expanded:true
}),
loader:new Ext.tree.TreeLoader({
dataUrl:'treeUtil.html?content.method=getAllMenuTreeNodes'
})
});
public void getAllMenuTreeNodes(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String systemId = request.getParameter("node");
String haveCheckBox = request.getParameter("haveCheckBox");
IMenuManager menuManager = this.getPkgServer().getDriver().getSystemManageServer().getMenuManager();
List<HashMap> nodes = new ArrayList<HashMap>();
String parentNodeName =menuManager.getMenu(Long.parseLong(systemId)).getName() ;
List<Menu> menus = menuManager.getMenus("em.parent_name= '" +parentNodeName + "'");
for(Menu menu:menus){
HashMap<String, Object> hm=new HashMap<String, Object>();
hm.put("id", menu.getId());
hm.put("text", menu.getTitle());
hm.put("iconCls",menu.getName());
nodes.add(hm);
}
JSONArray ary = new JSONArray(nodes);
writeJson(response, ary.toString());
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章