实现extjs 的下拉框回显,从后台数据库中的数据获得

 前台:

//卡点名称
var nameStore = new Ext.data.Store({ 
	proxy: new Ext.data.HttpProxy({ 
		url: jt.webContextRoot+'productionOfEvidence/findZhanDianName.action' }), 
	reader: new Ext.data.JsonReader( 
	{ nameList: "" },        //后台获得的数据,传给前台的数据集合
	["zhandianName"]         //json字符串的key
	) 
	});
nameStore.load(); 
//下拉框
var zhandianName= new Ext.form.ComboBox({
				fieldLabel : "站点名称",
				name:'zhandianName',
				id:'zhandianName',
				displayField: 'zhandianName',   //显示的字段
				triggerAction : 'all',
				store: nameStore,
				mode : 'local', // 数据会自动读取,如果设置为local又调用了store.load()则会读取2次;也可以将其设置为local,然后通过store.load()方法来读取
				editable : false,
				anchor : '100%',
		     })

后台:

public void findZhanDianName() throws BusinessException{
                //从数据库中获得数据
		List nameList = this.baseService.findObjects("productionOfEvidence.findZhanDianName", null);
		this.writeJson(nameList);//向前台传递json数据
	}

 

你可能感兴趣的:(extjs)