front desk:
The code copy is as follows:
var provinceStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: basePath + "/stationManage/station_getProvinceJSON.action" }),
reader: new Ext.data.JsonReader(
{ root: "" },
["PROVINCEID", "PROVINCENAME"]
)
});
//Select a province and city
var provinceIDadd = new Ext.form.ComboBox({
anchor : '98%',
id:'provinceIDadd',
name: "provinceIDAdd1",
hiddenName : "provinceID",
displayField : "PROVINCENAME",
valueField : "PROVINCEID",
blankText: 'Please select the province to which the site belongs',
emptyText: 'Please select the province to which the site belongs',
fieldLabel: 'The province to which the site belongs',
allowBlank : false,
editable : false,
triggerAction : 'all',
store:provinceStore,
forceSelection : true,
mode : 'local',
selectOnFocus: true
})
provinceStore.load();
Background action code
The code copy is as follows:
public class StationAction extends BaseAction {
private List<Map<String, Object>> provinceList;
public void setProvinceList(List<Map<String, Object>> provinceList) {
this.provinceList = provinceList;
}
public List<Map<String, Object>> getProvinceList() {
return provinceList;
}
public String getProvinceJSON(){
String sql="SELECT PK_ID PROVINCEID,NAME PROVINCENAME FROM T_DICT_DISTRICT A WHERE A.DISTRICT_LEVEL=20";
provinceList= stationService.findBySQL(sql);
return "json_getProvinceList";
}
}
strtus xml configuration
The code copy is as follows:
<result name="json_getProvinceList" type="json" >
<param name="root">provinceList</param>
</result>
Pull down selection box for loading static data
The code copy is as follows:
var dataType=[['0','8 columns'],['1','38 columns'],['2','21 columns']];
var dataTypeStore = new Ext.data.SimpleStore({
fields: ['dataTypeID', 'dataTypeName'],
data : data
});
var dataTypedd = new Ext.form.ComboBox({
anchor : '98%',
id:'dataTypeadd',
name: "dataTypeAdd1",
hiddenName : "dataType",
displayField : "dataTypeName",
valueField : "dataTypeID",
blankText: 'Please select the data format',
emptyText: 'Please select the data format',
fieldLabel: 'data format',
allowBlank : false,
editable : false,
triggerAction : 'all',
store :unitStore ,
forceSelection : true,
mode : 'local',
selectOnFocus: true
})