extjs之动态刷新活动的tab页

Ext.define('Business.view.businessRequest.BrUnitRuleTabPanel',{
extend:'Ext.tab.Panel',
border:false,
id:'brUnitRuleTabPanel',
iconCls:'application_side_list',
alias : 'widget.brUnitRuleTabPanel',
initComponent: function() {
var unitRuleTabPanel = this;
Ext.apply(this, {
layout : 'border',
defaults : {
collapsible : false,
split : true,
bodyStyle : 'padding:0px'
},
items: [
{

title: '关联交易/步骤',

id:'gljybzGrid',
xtype:'brUnitFunctionSteprulePanel'

},
{

title: '规则影响分析',

id:'gzyxfxGrid',
xtype:'brUnitRuleEffectPanel'

},
{

title: '影响范围(关联)',

id:'yxfwglGrid',
xtype:'brUnitRuleEffectscopePanel'

}
]
});


/**
* 业务规则更改时调用的方法
* @param id
*/

this.refreshTabDate = function(id){

//把规则模块的id赋给unitRuleTabPanel的属性

unitRuleTabPanel.selectBrUnitRuleId = id;

//获得活动中的Tab页

var activeTabPanel = unitRuleTabPanel.getActiveTab();
//刷新数据

activeTabPanel.selectBrUnitRuleId = id;

//如果在活动中的tab页中有refreshDate方法

if(activeTabPanel.refreshDate){

//执行refreshDate()方法,方法一般写刷刷新的store

activeTabPanel.refreshDate();
}
};
/**
* tab改变,刷新tab中数据
*/
unitRuleTabPanel.on('tabchange',function(tabPanel,newCard,oldCard,eOpts){

var activeTabPanel = tabPanel.getActiveTab();

//比对选中的tab的ruleId是否是先前的ruleId,如果不是就刷新

if(unitRuleTabPanel.selectBrUnitRuleId != activeTabPanel.selectBrUnitRuleId){

//把当前的ruleId赋给活动Tab的ruleId

activeTabPanel.selectBrUnitRuleId = unitRuleTabPanel.selectBrUnitRuleId;
if(activeTabPanel.refreshDate){
activeTabPanel.refreshDate();
}
}
});
this.callParent(arguments);
}

});


需要在关联交易/步骤、'规则影响分析、影响范围模块中添加refreshDate();方法刷新模块中的store;

各个模块中的stroe需要在beforeLoad之前加ruleId传到后台执行查询

listeners : {
beforeload : {
fn : function(store, options) {
var brUnitRuleId = Ext.getCmp('brUnitRuleTabPanel').selectBrUnitRuleId;
Ext.apply(store.proxy.extraParams, {
'pageNum' : this.pageNum,
'pageSize': this.pageSize,
'effectName':this.condition,
'ruleId':brUnitRuleId
});
}
}
}

你可能感兴趣的:(ExtJs)