前台:
// 后台接口数据
var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'store/getStoreInfo.action' }),
reader: new Ext.data.JsonReader(
{ nameList: "" }, //后台获得的数据,传给前台的数据集合
["storeName"] //json字符串的key
)
});
dataStore.load();
// 下拉框
var storeName = new Ext.form.ComboBox({
fieldLabel : "名称",
name:'storeName',
id:'storeName',
displayField: 'storeName', //显示的字段
triggerAction : 'all',
store: dataStore,
mode : 'local', // 数据会自动读取,如果设置为local又调用了store.load()则会读取2次;也可以将其设置为local,然后通过store.load()方法来读取
editable : false,
anchor : '100%',
})
后台:
public void getStoreInfo() throws BusinessException{
//从数据库中获得数据
List<ProductionOfEvidenceVO> nameList = this.baseService.findObjects("store.getStoreInfo", null);
this.writeJson(nameList);//向前台传递json数据
}