1、静态
[javascript] view plaincopy
var staticComboBox = new Ext.form.ComboBox({
fieldLabel:'回访结果',
name:'result',
hiddenName:'result',
anchor:'100%',
editable:false,
readOnly:true,
mode:'local',
triggerAction:'all',
store:new Ext.data.SimpleStore({
fields:['code','desc'],
data:[
['全部','全部'],
['回访成功','回访成功'],
['无人','无人'],
['错号','错号'],
['停机','停机']
],
autoLoad:true
}),
value:'全部',
valueField:'code',
displayField:'desc'
});
2、动态:
[javascript] view plaincopy
//前台
var dynamicComboBox = new Ext.form.ComboBox({
fieldLabel:'回访人员',
hiddenName:'operator',
name: 'operator',
mode: 'remote',
triggerAction:'all',
anchor:'100%',
editable : false,
readOnly:true,
store:
new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:'TestAction!loadOperator.action'
}),
reader:new Ext.data.JsonReader({
root: 'root',
totalProperty: 'totalProperty',
fields:['code','desc']
}
),
autoLoad:true
}),
valueField: 'code', //值字段
displayField: 'desc', //显示字段
value:'全部'
});
//后台参见:http://blog.csdn.net/xieshengjun2009/archive/2010/10/22/5959687.aspx
3、动态取值后 - 前台另添加一条记录:
[javascript] view plaincopy
var record = Ext.data.Record.create([
{name:'code',type:'string',mapping:'0'},
{name:'desc',type:'string',mapping:'1'}
]);
var newRecord = new record({code:'全部',desc:'全部'});
var store = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'TestAction!loadGroupName.action'}),
reader:new Ext.data.JsonReader({
totalProperty:'results',
root:'rows',
fields:[
{name:'code'},
{name:'desc'}
]
}),
autoLoad:true,
listeners:{'load':function(){
store.add(newRecord);
}
}
});
var groupNameComboBox = new Ext.form.ComboBox({
name:'groupName',
130,
readOnly:true,
emptyText:'请选择',
valueField:'code', //逻辑列名的实际值(code)
displayField:'desc', //逻辑列名的显示值(decs)
triggerAction:'all',
editable : false,
140,
anchor:'100%',
store:store
4、动态取值后 - 后台另添加一条记录:
前台:
[javascript] view plaincopy
var dynamicComboBox = new Ext.form.ComboBox({
fieldLabel:'回访人员',
hiddenName:'operator',
name: 'operator',
mode: 'remote',
triggerAction:'all',
anchor:'100%',
editable : false,
readOnly:true,
store:
new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:'TestAction!loadOperator.action'
}),
reader:new Ext.data.JsonReader({
root: 'root',
totalProperty: 'totalProperty',
fields:['code','desc']
}
),
autoLoad:true
}),
valueField: 'code', //值字段
displayField: 'desc', //显示字段
value:'全部'
});
后台:
[java] view plaincopy
Opterator optr = new Opterator();//返回的列表对象(自定义)
List<Opterator> list = testService.loadtOpterator(map);
Iterator<Opterator> it = list.iterator();
int i=0;
//将list列表数据封装成json格式的数据
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
JSONObject jsonAll = new JSONObject();
jsonAll.put("code", "全部");
jsonAll.put("desc", "全部");
jsonArray.put(i++, jsonAll);
while(it.hasNext()){
JSONObject jsonObj = new JSONObject();
optr = (Opterator)it.next();
jsonObj.put("code", sr.getOptr());
jsonObj.put("desc", sr.getOptr());
jsonArray.put(i++, jsonObj);
}
jsonObject.put("totalProperty", list.size());
jsonObject.put("root", jsonArray);
// 输出到前台
outJsonString(jsonObject.toString());
第五种:直接在store的回掉函数里调用:
store.load({
callback: function(records, operation, success) {
store.insert(store.getCount()+1,[{'code':0,'desc':'全部'}])
},
scope: this
});
---------------------
作者:申公
来源:CSDN
原文:https://blog.csdn.net/haitaofeiyang/article/details/50204533?utm_source=copy
版权声明:本文为博主原创文章,转载请附上博文链接!