這篇文章主要介紹了extcombobox動態(tài)加載數(shù)據(jù)庫數(shù)據(jù)并附前后臺實(shí)現(xiàn),需要的朋友可以參考下。
前臺:
代碼如下:
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:'請選擇站點(diǎn)所屬省份',
emptyText:'請選擇站點(diǎn)所屬省份',
fieldLabel:'站點(diǎn)所屬省份',
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>
加載靜態(tài)數(shù)據(jù)的下拉選擇框
代碼如下:
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:'請選擇數(shù)據(jù)格式',
emptyText:'請選擇數(shù)據(jù)格式',
fieldLabel:'數(shù)據(jù)格式',
allowBlank:false,
editable:false,
triggerAction:'all',
store:unitStore,
forceSelection:true,
mode:'local',
selectOnFocus:true
})
更多信息請查看IT技術(shù)專欄