var cgcodeStore = new Ext.data.JsonStore({
url : 'demand_getCorpCGCode.do',
totalProperty:'totalCount',
root:'data',
fields : [
{name : 'cgcode',type : 'string'},
{name : 'rownum',type : 'string'}
]
});
//这里定义comboBox
var co_cgcode = new Ext.form.ComboBox({
//xtype : 'combo',
//labelStyle : '{font-weight:bold}',
id : this.genId('p_cgcode'),
name:'p_cgcode',
triggerAction:'all',
mode:'local',
store : cgcodeStore,
editable:false,
editable : false,
allowBlank : false,
autoLoad:true,
//blankText : '发卡集团编号不能为空',
valueField : 'cgcode',
//tpl:'<tpl for="."><div class="x-combo-list-item">[{cgcode}]{cgname}</div></tpl>',
displayField : 'cgcode',
listeners:{
scope:this,
render:{
fn:function(sto,opt){
//alert("==="+sto.getStore().getCount());
//cgcodeStore.getAt(0);
}
},
select:function(sto,opt){
//alert("===---"+sto.getStore().getCount());
}
}
});
//关键是这里:直接加载store,在加载时调用回调函数,在回调函数里给comboBox赋初始值,然后根据初始值调用grid的Store加载,
cgcodeStore.load({
callback : function(){
//alert(cgcodeStore.getCount());
co_cgcode.setValue(cgcodeStore.getAt(0).get('cgcode'));
_cgcode=cgcodeStore.getAt(0).get('cgcode');
demandmsStore.load({
params : {
corpid:gCorpId,
cgcode:_cgcode,
start : 0,
limit : gLimit
}
});
}
});
-----------------------------------------------------------------------------------------------------------------------------------