1、靜态
- 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、動态:
- //前台
- 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、動态取值後 - 前台另添加一條記錄:
- 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',
- width:130,
- readOnly:true,
- emptyText:'請選擇',
- valueField:'code', //邏輯列名的實際值(code)
- displayField:'desc', //邏輯列名的顯示值(decs)
- triggerAction:'all',
- editable : false,
- width:140,
- anchor:'100%',
- store:store
4、動态取值後 - 背景另添加一條記錄:
前台:
- 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:'全部'
- });
背景:
- 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());