摘要:jQuery treepanel动态加载数据实现代码如下: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()); }

脚本宝典收集整理的这篇文章主要介绍了

js实例教程-jQuery treepanel动态加载数据实现代码

脚本宝典小编觉得挺不错的,现在分享给大家,也给大家做个参考,希望能帮助你少写一行代码,多一份安全和惬意。

小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

jQuery treepanel动态加载数据实现代码如下:

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());
}

jQuery treepanel动态加载数据实现代码如下:

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());
}

觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!

总结

以上是脚本宝典为你收集整理的

js实例教程-jQuery treepanel动态加载数据实现代码

全部内容,希望文章能够帮你解决

js实例教程-jQuery treepanel动态加载数据实现代码

所遇到的程序开发问题,欢迎加入QQ群277859234一起讨论学习。如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典网站推荐给程序员好友。 本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。

80%的人都看过