您的位置:首页 > 其它

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

2014-12-26 09:10 363 查看
这两天研究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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: