struts2 Ext3 jsvm jsonplugin 树形菜单
在firefox没有出错,菜单会显示,在IE上只显示只显示一个根节点 只执行到1 ,2 执行不到
Ext.namespace("sys");
sys.WestPanel = Ext.extend(Ext.Panel, {
constructor : function(cfg) {
if(!cfg)
cfg = {};
Ext.applyIf(cfg, {
layout:'accordion',
title : '我的地盘我作主',
border : false,// 无边框样式
width : 180,// 必须指定
collapsible : true,// 收缩
split : true,// 拖动
collapseMode : 'mini',// 前提要能拖动
id:'westPanel'
});
var self = this;
Ext.Ajax.request({
url: 'menu/menuAction!show.do',
method:'post',
success:function(response, opts){
var data = Ext.decode(response.responseText);
alert(Ext.encode(data));
for(var i=0; i<data.length; i++){
//alert(Ext.encode(data[i]));
var m = data[i];
var p = new Ext.tree.TreePanel({
title:m.text,
border:false,
bodyBorder:false,
root:m,
region:'west',
iconCls:'firstMenu',
rootVisible:false,
listeners:{
'click':function(node){
}
}
});
self.add(p);
}
alert("1");
self.doLayout();//这里不能执行
alert("2");
},
failure:function(){
Ext.MessageBox.alert("错误", "操作失败");
}
});
sys.WestPanel.superclass.constructor.call(this, cfg);
}
});
menu/menuAction!show.do和alert(Ext.encode(data));打印出来的数据一样,数据如下
[{"children":[{"children":[],"icon":"images\/icon\/node.gif","id":21,"leaf":true,"panelClass":null,"text":"角色信息管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":22,"leaf":true,"panelClass":null,"text":"职员信息管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":23,"leaf":true,"panelClass":"sys.dept.DeptPanel","text":"部门管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":24,"leaf":true,"panelClass":null,"text":"登录日志管理","url":null}],"icon":"images\/icon\/node.gif","id":2,"leaf":false,"panelClass":null,"text":"系统管理","url":null},{"children":[{"children":[],"icon":"images\/icon\/node.gif","id":31,"leaf":true,"panelClass":null,"text":"客户信息管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":32,"leaf":true,"panelClass":null,"text":"外部订单管理","url":null}],"icon":"images\/icon\/node.gif","id":3,"leaf":false,"panelClass":null,"text":"市场部","url":null},{"children":[{"children":[],"icon":"images\/icon\/node.gif","id":41,"leaf":true,"panelClass":null,"text":"内部订单管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":42,"leaf":true,"panelClass":null,"text":"产品库存管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":43,"leaf":true,"panelClass":null,"text":"材料库存管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":44,"leaf":true,"panelClass":null,"text":"产品出库管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":45,"leaf":true,"panelClass":null,"text":"产品入库管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":46,"leaf":true,"panelClass":null,"text":"材料入库管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":47,"leaf":true,"panelClass":null,"text":"材料出库管理","url":null}],"icon":"images\/icon\/node.gif","id":4,"leaf":false,"panelClass":null,"text":"仓储部","url":null},{"children":[{"children":[],"icon":"images\/icon\/node.gif","id":51,"leaf":true,"panelClass":null,"text":"产品管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":52,"leaf":true,"panelClass":null,"text":"材料管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":53,"leaf":true,"panelClass":null,"text":"产品类型管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":54,"leaf":true,"panelClass":null,"text":"材料类型管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":55,"leaf":true,"panelClass":null,"text":"生产单管理","url":null}],"icon":"images\/icon\/node.gif","id":5,"leaf":false,"panelClass":null,"text":"生产部","url":null},{"children":[{"children":[],"icon":"images\/icon\/node.gif","id":61,"leaf":true,"panelClass":null,"text":"供应商管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":62,"leaf":true,"panelClass":null,"text":"采购单管理","url":null},{"children":[],"icon":"images\/icon\/node.gif","id":63,"leaf":true,"panelClass":null,"text":"订购单管理","url":null}],"icon":"images\/icon\/node.gif","id":6,"leaf":false,"panelClass":null,"text":"采购部","url":null}]
这是为什么
[解决办法]
var tree = new Ext.tree.TreePanel({
title:'我的地盘',
animate:true,
autoScroll:true,
loader:new Ext.tree.TreeLoader({
dataUrl:'sys/menuAction!loadChild.do'
}),
enableDD:true,
containerScroll:true,
rootVisible:false,
border:false,
dropConfig:{
appendOnly:true
},
root:new Ext.tree.AsyncTreeNode({
draggable:false,
id:'1',
expand:true
}),
listeners:{
'click':function(node){
openModule(node.attributes, node.getUI().getEl());
}
}
});
自己慢慢看