如何用Ext的ComboBox动态加载数据库中的数据
推荐于2016-02-23 · 知道合伙人金融证券行家
关注
展开全部
代码如下:
varprovinceStore=newExt.data.Store({
proxy:newExt.data.HttpProxy({url:basePath+"/stationManage/station_getProvinceJSON.action"}),
reader:newExt.data.JsonReader(
{root:""},
["PROVINCEID","PROVINCENAME"]
)
});
//选择省市
varprovinceIDadd=newExt.form.ComboBox({
anchor:'98%',
id:'provinceIDadd',
name:"provinceIDAdd1",
hiddenName:"provinceID",
displayField:"PROVINCENAME",
valueField:"PROVINCEID",
blankText:'请选择站点所属省份',
emptyText:'请选择站点所属省份',
fieldLabel:'站点所属省份',
allowBlank:false,
editable:false,
triggerAction:'all',
store:provinceStore,
forceSelection:true,
mode:'local',
selectOnFocus:true
})
provinceStore.load();
后台action代码
代码如下:
publicclassStationActionextendsBaseAction{
privateList<Map<String,Object>>provinceList;
publicvoidsetProvinceList(List<Map<String,Object>>provinceList){
this.provinceList=provinceList;
}
publicList<Map<String,Object>>getProvinceList(){
returnprovinceList;
}
publicStringgetProvinceJSON(){
Stringsql="SELECTPK_IDPROVINCEID,NAMEPROVINCENAMEFROMT_DICT_DISTRICTAWHEREA.DISTRICT_LEVEL=20";
provinceList=stationService.findBySQL(sql);
return"json_getProvinceList";
}
}
strtusxml配置
代码如下:
<resultname="json_getProvinceList"type="json">
<paramname="root">provinceList</param>
</result>
加载静态数据的下拉选择框
代码如下:
vardataType=[['0','8列'],['1','38列'],['2','21列']];
vardataTypeStore=newExt.data.SimpleStore({
fields:['dataTypeID','dataTypeName'],
data:data
});
vardataTypedd=newExt.form.ComboBox({
anchor:'98%',
id:'dataTypeadd',
name:"dataTypeAdd1",
hiddenName:"dataType",
displayField:"dataTypeName",
valueField:"dataTypeID",
blankText:'请选择数据格式',
emptyText:'请选择数据格式',
fieldLabel:'数据格式',
allowBlank:false,
editable:false,
triggerAction:'all',
store:unitStore,
forceSelection:true,
mode:'local',
selectOnFocus:true
})
varprovinceStore=newExt.data.Store({
proxy:newExt.data.HttpProxy({url:basePath+"/stationManage/station_getProvinceJSON.action"}),
reader:newExt.data.JsonReader(
{root:""},
["PROVINCEID","PROVINCENAME"]
)
});
//选择省市
varprovinceIDadd=newExt.form.ComboBox({
anchor:'98%',
id:'provinceIDadd',
name:"provinceIDAdd1",
hiddenName:"provinceID",
displayField:"PROVINCENAME",
valueField:"PROVINCEID",
blankText:'请选择站点所属省份',
emptyText:'请选择站点所属省份',
fieldLabel:'站点所属省份',
allowBlank:false,
editable:false,
triggerAction:'all',
store:provinceStore,
forceSelection:true,
mode:'local',
selectOnFocus:true
})
provinceStore.load();
后台action代码
代码如下:
publicclassStationActionextendsBaseAction{
privateList<Map<String,Object>>provinceList;
publicvoidsetProvinceList(List<Map<String,Object>>provinceList){
this.provinceList=provinceList;
}
publicList<Map<String,Object>>getProvinceList(){
returnprovinceList;
}
publicStringgetProvinceJSON(){
Stringsql="SELECTPK_IDPROVINCEID,NAMEPROVINCENAMEFROMT_DICT_DISTRICTAWHEREA.DISTRICT_LEVEL=20";
provinceList=stationService.findBySQL(sql);
return"json_getProvinceList";
}
}
strtusxml配置
代码如下:
<resultname="json_getProvinceList"type="json">
<paramname="root">provinceList</param>
</result>
加载静态数据的下拉选择框
代码如下:
vardataType=[['0','8列'],['1','38列'],['2','21列']];
vardataTypeStore=newExt.data.SimpleStore({
fields:['dataTypeID','dataTypeName'],
data:data
});
vardataTypedd=newExt.form.ComboBox({
anchor:'98%',
id:'dataTypeadd',
name:"dataTypeAdd1",
hiddenName:"dataType",
displayField:"dataTypeName",
valueField:"dataTypeID",
blankText:'请选择数据格式',
emptyText:'请选择数据格式',
fieldLabel:'数据格式',
allowBlank:false,
editable:false,
triggerAction:'all',
store:unitStore,
forceSelection:true,
mode:'local',
selectOnFocus:true
})
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询