关于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);
}
最后发现在定义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);
}
相关文章推荐
- 关于页面第一次加载判断所传参数的问题:
- 关于Picasso回调获取bitmap第一次加载失败的问题
- 关于Ext.grid.Panel显示远程数据无法加载问题的解决
- 关于fragment嵌套fragment,第一次能加载布局,第二次不能加载布局的问题
- 关于Ext的Combo加载数据的问题。
- 关于Glide加载圆形图片,第一次加载时出现不显示的问题
- EXT关于树节点的children属性加载的问题
- 关于Ext的Combo加载数据的问题。
- 关于Ext的Combo加载数据的问题。
- 关于Webview在RecyclerView的第一个条目中,第一次加载时点击回顶部的问题
- 关于同一个dll被多个进程加载的共享问题
- 关于WPF的ComboBox中Items太多而导致加载过慢的问题
- window.onload 关于页面加载完毕的问题
- 关于GridView中默认显示页码的问题
- 关于EXT 动态异步加载Tree
- 关于WPF的ComboBox中Items太多而导致加载过慢的问题
- 关于控件postback 后viewstate加载失败的问题
- 关于在Google Earth中动态加载地标问题
- 关于ext.grids常见问题(Frequently asked questions about grids):
- 关于默认共享问题