核心代码如下:(注意名称的对应!)
服务器生成的json数据形如:
[{"ACTIONNAME":"http_get","ACTIONVALUE":"3"},{"ACTIONNAME":"http_post","ACTIONVALUE":"4"}]
var actionStore = new Ext.data.Store({ //定义store数据
proxy: new Ext.data.HttpProxy({
url: 'action.jsp?type=loadAction' //递交到服务器的url
}),
reader: new Ext.data. JsonReader({},['ACTIONNAME', 'ACTIONVALUE']) //数据域
});
{ //combox组件
fieldLabel: '提交方式',
xtype: "combo",
store: actionStore, //对应actionStore数据对象
mode: 'local',
triggerAction: 'all',
allowBlank: false,
displayField: 'ACTIONNAME', //显示的名称,与数据域对应的
valueField: 'ACTIONVALUE', //ACTIONNAME对应值
blankText: '请选择提交方式!',
editable: false,
emptyText: '-请选择提交方式-',
hiddenName: 'ACTIONSUBMIT', //提交时候的名字
selectOnFocus: true,
anchor: "95%"
}