Front-end:
Copy codeThe Code 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/City
Var provinceIDadd = new Ext. form. ComboBox ({
Anchor: '20140901 ',
Id: 'provinceidadd ',
Name: "provinceIDAdd1 ",
HiddenName: "provinceID ",
DisplayField: "PROVINCENAME ",
ValueField: "PROVINCEID ",
BlankText: 'select the province to which the site belongs ',
EmptyText: 'select the province to which the site belongs ',
FieldLabel: '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
Copy codeThe Code 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
Copy codeThe Code is as follows:
<Result name = "json_getProvinceList" type = "json">
<Param name = "root"> provinceList </param>
</Result>
Drop-down box for loading static data
Copy codeThe Code is as follows:
Var dataType = [['0', '8 columns '], ['1', '38 columns'], ['2', '21 columns '];
Var dataTypeStore = new Ext. data. SimpleStore ({
Fields: ['peypeid', 'datatypename'],
Data: data
});
Var dataTypedd = new Ext. form. ComboBox ({
Anchor: '20140901 ',
Id: 'peypeadd ',
Name: "dataTypeAdd1 ",
HiddenName: "dataType ",
DisplayField: "dataTypeName ",
ValueField: "dataTypeID ",
BlankText: 'select data format ',
EmptyText: 'select data format ',
FieldLabel: 'Data format ',
AllowBlank: false,
Editable: false,
TriggerAction: 'all ',
Store: unitStore,
ForceSelection: true,
Mode: 'local ',
SelectOnFocus: true
})