Ext 向Ext.form.ComboBox()中添加列表的分类
2010-11-06 17:14
288 查看
1、静态
2、动态:
3、动态取值后 - 前台另添加一条记录:
4、动态取值后 - 后台另添加一条记录:
前台:
后台:
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());
相关文章推荐
- Ext 向Ext.form.ComboBox()中添加列表的分类
- Ext.form.ComboBox加载json时刻默认选中的解决
- Ext.form.field.ComboBox 切换store没有反应
- 禁止Ext.form.ComboBox远程获取数据的方法
- Extjs4中的Form之下拉列表combobox的使用
- 添加字段列表到ComboBox
- 动态给Sharepoint的列表的三个Form添加Webparts
- 使用Ext中的Grid,Form,Dialog来实现列表,创建,更新,删除,查找和分页功能
- 【转】使用ComboBox.Items的Add方法添加列表项
- 用一个form表单实现一次性无限极分类添加功能
- 动态Ext.form.Combobox的写法<案例>
- Ext.form.ComboBox显示错误的问题
- Ext.form.ComboBox 完整属性
- 可输入可联想的下拉列表的实现——Ext ComboBox
- Octopress 搭建静态博客站点 --- 为站点侧边栏添加分类列表(Categories)
- ext2.2打造Ext.form.ComboBox系列--树形结构
- easyUI添加下拉列表 +++ form表单点一次,向后台提交两次
- Ext.form.ComboBox 属性详解(见注释)及使用方法
- Ext.form.field.ComboBox结合Servlet、JSON实现AutoComplete