Ext异步加载树(TREE)

jsp页面:

var tree;
var ne;
var rightshowMenu;
Ext.onReady(function(){
Ext.BLANK_IMAGE_URL="ext/resources/images/aero/s.gif";

var loader = new Ext.tree.TreeLoader({
url: "bookShop.do?parameter=treedata"
});

loader.on("beforeload", function(loader, node){
this.baseParams.id = (node.id);
});
var root = new Ext.tree.AsyncTreeNode({
id: "root",
text: "",
draggable: true //设置根节点是否可拖拽
});

tree = new Ext.tree.TreePanel({
renderTo: "tree-div",
useArrows: true,
autoScroll: true,
animate: true,
containerScroll: true,
rootVisible: false,
border: false,
root:root,
enableDD: true//允许拖拽
// listeners:{contextmenu:showMenu}
});
<%
for(int i=0;i<listrose.size();i++)
{
Rose rose=listrose.get(i);
%>
var croot=new Ext.tree.AsyncTreeNode({
id:"<%=rose.getId()%>",
text:"<%=rose.getName()%>",
allowDrag: false, // 在部门树里面,组织不支持拖拽
loader: loader
});
root.appendChild(croot);
<%
}
%>
tree.getRootNode().expand();
});


java:
public ActionForward treedata(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String id = request.getParameter("id");
log.info("展开节点根据 节点ID::" + id + ",获取子节点信息!");
List<Rose> list = roseBiz.resutlRosebyid(id);

JSONArray json = new JSONArray();
if (null != id && id.length() > 0) {
for (Rose rose : list) {
JSONObject temp = new JSONObject();
temp.put("id", rose.getId());
temp.put("text", rose.getName());
json.add(temp);
}
}else
{
log.info("节点下为空!");
}
log.info("展开节点,获取节点下面的信息:格式化返回::" + json.toString());
writerJSON(response, json.toString());
return null;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值