项目中用到EXT作一个二级联动,由于刚接触EXT,故不太熟悉,对于combox store动态传参有些问题没想通。下面先把正确的代码贴出,请批评指正:
?
第一个combox:
?
{
id : 'OfficeID',
xtype:'combo',
triggerAction: 'all',
labelSeparator:' ',
fieldLabel: '局向<font color=red>*</font>: ',
anchor:'90%',
store:new Ext.data.Store
({
autoLoad:true,
proxy:new Ext.data.HttpProxy
({
url: "<%=request.getContextPath() %>/inck/query/inckAdslDevNeAction.do?method=userOfficeRightList"
}),
reader: new Ext.data.JsonReader
(
{root: "datas"},
[
{name:"OFFICE_ID",type:'string'},
{name:"OFFICE_NAME",type:'string'}
]
),
listeners:?
{
load: function(store)
{?
if(store.getTotalCount()==1)
{
Ext.getCmp("OfficeID").setValue(store.getAt(0).get('OFFICE_ID'));?
alert(Ext.getCmp("OfficeID").getValue());
}
}?
}
}),
valueField : "OFFICE_ID",
typeAhead : true,
displayField : "OFFICE_NAME",
emptyText : '请选择局向',
mode : 'local',
editable:false,
lazyInit:false,
forceSelection:true,
listeners:
{
"select": function(combo)
{
officeSelect=Ext.getCmp("OfficeID").getValue();
alert(officeSelect);
Ext.getCmp('dslamip').clearValue();?
// Ext.getCmp('dslamip').store.reload();?
Ext.getCmp('dslamip').store.load({params:{OFFICE_ID:officeSelect}});//这里给第二个combox赋值成功
//document.getElementById('officeName').value = "";
// document.getElementById('officeIdTreeCode').value = "";
}
?
}
}
?
?
?
?
第二个combox:
?
? {
id : 'dslamip',
xtype:'combo',
triggerAction: 'all',
labelSeparator:' ',
fieldLabel: 'DSLAMIP <font color=red>*</font>: ',
anchor:'90%',
store:new Ext.data.Store
({
//autoLoad:true,
proxy:new Ext.data.HttpProxy
({
url: "<%=request.getContextPath() %>/inck/query/inckAdslDevNeAction.do?method=userOfficeDSLAMIPList"// url: "<%=request.getContextPath() %>/inck/query/inckAdslDevNeAction.do?method=userOfficeDSLAMIPList&OfficeID='100307'"这里静态赋值成功,但用变量代替就不行,也不知道为什么啊
}),
reader: new Ext.data.JsonReader
(
{root: "dslamip_datas"},
[
{name:"dslamip",type:'string'}
]
),
// baseParams: { OFFICE_ID:officeSelect} ,//这里动态赋参数不成功,不知道为什么?
listeners:?
{
load: function(store)
{?
if(store.getTotalCount()==1)
{
//Ext.getCmp("OfficeID").setValue(store.getAt(0).get('OfficeID'));?
//document.getElementById('officeName').value = "";
//document.getElementById('officeIdTreeCode').value = "";
}
}?
}
}),
valueField : "dslamip",
typeAhead : true,
displayField : "dslamip",
emptyText : '请选择DSLAM IP',
mode : 'local',
editable:false,
lazyInit:false,
forceSelection:true
}
?
?
?