关于Ext的TreeStore会第一次默认加载的问题

这两天研究Tree,总体功能是好了 ,但就是在将那个js加载之后,每次都会向后台访问东西(如下图),研究了各种属性,发现都不起作用


最后发现在定义TreeStore时,不要定义Proxy,而是在panal初始化的时候进行setProxy问题就会解决,如下面的代码

var roleTreeStore = Ext.create('Ext.data.TreeStore', {
// proxy : {
// method:'post',
// type : 'ajax',
// url : 'mystruts/getAllRolesRightAndAplly.do',
// reader : {
// type : 'json'
// }
// },



root : {
text : '角色菜单',
id : '0',
expanded : true
}
});

Ext.jy.syssetting.UserRoleTreePanel = Ext.extend(Ext.tree.Panel, {
userId : null,
userName : null,
useArrows : true,
width : 200,
height : 150,
store : roleTreeStore,
rootVisible : true,
renderTo : Ext.getBody(),
initComponent : function() {
var expand = new Ext.Button({
icon : 'images/expand-all.gif',
tooltip : '全部展开'
});
expand.on('click', this.expandAllMenu, this);
var collapse = new Ext.Button({
tooltip : '全部收起',
icon : 'images/collapse-all.gif'
});
collapse.on('click', this.collapseAllMenu, this);
var refresh = new Ext.Button({
icon : 'images/refresh.gif',
tooltip : '刷新'
});
refresh.on('click', this.refreshAllMenu, this);
this.tbar = [expand, collapse, refresh];
roleTreeStore.setProxy({
method : 'post',
type : 'ajax',
url : 'mystruts/getAllRolesRightAndAplly.do',
reader : {
type : 'json'
}
});

roleTreeStore.load({
params : {
'userBean.userID' : this.userId
}
});
Ext.jy.syssetting.UserRoleTreePanel.superclass.initComponent
.apply(this, arguments);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值