EXTJS4 TREE 加载前 传参问题

Ext 的树总是会自动加载,这就给加载时附带参数到后台带来了困难。

有几种解决方案:

1、在构建treestore时,在URL中传入参数,这中方式需要每次都重新构建store(也就是需要将原来的视图删除,再通过Ext.create创建树视图)

2、添加beforeload事件

 

var store = Ext.create('Ext.data.TreeStore', {
			model : 'Tms.model.TreeInfo',
			clearOnLoad : true,
			proxy : {
				type : 'ajax',
				url : 'sys.sp?method=getJurisdictionScope'
			},
			listeners : {
				exception : function(proxy, response, operation) {
					Ext.MessageBox.show({
						title : '服务器错误',
						msg : operation.getError(),
						icon : Ext.MessageBox.ERROR,
						buttons : Ext.Msg.OK
					});
				},
				beforeload : function(store, operation) {
					if(!me.getQtId()){// 前端传递过来的参数,如果为空不加载
						return false;
					}
					var new_params = {//参数
						qtId : me.getQtId()
					};
					Ext.apply(store.proxy.extraParams, new_params);// 通过extraParams传递
				}
			}
});

 

设置参数,并调用tree的load方法重新加载树

 

loadJurScope : function(selModel, selected){
		if(selected && selected[0]){
			var record = selected[0];
			var jsManage = this.getJsManage();
			jsManage.setQtId(record.get('qtId'));
			var deptTree = jsManage.down('#deptTree');
			deptTree.getStore().load();
		}
	}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值