基于对象的EXT组件间通信

基于对象的EXT组件间通信

问题提出:主界面上有上下两个gridPanel,在点击上面的gridPanel的时候,触发下面的gridPanel事件,如联动表格

解决方案:
1.在 GridPanel_1 中注册一个事件

this.addEvents({'onClickGridRow':true});

2.获取GridPanel_1的行点击事件

this.on({'rowclick':this.onGetSelectionModel,scope:this});

3.GridPanel_1 行点击事件函数获取行的记录,并触发自定义事件

onGetSelectionModel:function(){
      var sm = this.getSelectionModel();
      var record=sm.getSelected();
   this.fireEvent('onClickGridRow',record);
}

4.在父组件中获取自定义事件

this.aGrid = this.items.itemAt(0);
this.aGrid.on({'onClickGridRow':this.onRecordFromGrid,scope:this});

5.父组件自定义事件处理函数中调用gridPanel_2的方法
,onRecordFromGrid:function(record){
 this.bGrid = this.items.itemAt(1);
 this.bGrid.refreshBGrid(record);
}

6.在gridPanel_2中定义事件处理方法
,refreshBGrid:function(record){
 alert(record.get('id'));
 this.getStore().baseParams['id'] = record.get('id');
 this.getStore().reload();
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值