前台:
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"] ) }); //选择省市 var provinceIDadd = new Ext.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();
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配置
<result name="json_getProvinceList" type="json" > <param name="root">provinceList</param> </result>
加载静态数据的下拉选择框
var dataType=[['0','8列'],['1','38列'],['2','21列']]; 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 : '请选择数据格式', emptyText : '请选择数据格式', fieldLabel : '数据格式', allowBlank : false, editable : false, triggerAction : 'all', store :unitStore , forceSelection : true, mode : 'local', selectOnFocus : true })
ext combobox动态加载数据库数据,布布扣,bubuko.com
原文地址:http://blog.csdn.net/shanhuhau/article/details/31765885