EXTjs loadRecord方法 将grid中的数据 加载到form表单中去
2011-08-22 14:34
836 查看
重点是rowselect: function(sm, row, rec) {Ext.getCmp("user_info").getForm().loadRecord(rec);}这句代码sm是选择模式row是所列的唯一ID,比如第一条记录这个值就是0,以此递推!rec就表示本条记录
![](http://hi.csdn.net/attachment/201108/22/0_13139949032IMS.gif)
js页面代码
Ext.onReady(function(){ Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget="qtip"; var data = [ ["1","男",new Date(1979,09,06),"tom",21,"you_5214@sina.com"], ["2","女",new Date(1980,08,07),"tony",46,"you_5214@sina.com"], ["3","男",new Date(1990,07,08),"Jet Li",31,"you_5214@sina.com"], ["4","女",new Date(1910,06,09),"washington",29,"you_5214@sina.com"], ["5","女",new Date(1910,06,09),"washington",29,"you_5214@sina.com"] , ["6","女",new Date(1910,06,09),"washington",29,"you_5214@sina.com"] ]; var fields = ['id','sex','brithday','name','age','email']; function age(value){ if(value>30&&value<50) return '<span style="color:green;">' + value + '</span>'; else return '<span style="color:red;">'+value+'</span>'; }; function sex(value){ if(value=="男") return '<span style="color:red;">'+value+'</span>'; else return '<span style="color:green;">' + value + '</span>'; }; var cm = new Ext.grid.ColumnModel([ { header: "ID", width: 60, sortable: true,dataIndex :'id', editor:new Ext.form.TextField({allowBlank:false}) }, { header: "性别", width: 70, sortable: true,dataIndex :'sex', renderer:sex, editor:new Ext.grid.GridEditor(new Ext.form.ComboBox({ editable:false, allowBlank:false, displayField:"sex", valueField:"sex", triggerAction:"all", mode:"local", store:new Ext.data.SimpleStore({ fields:["sex"], data:[["男"],["女"]] }) }) ) }, { header: "生日", width: 130, sortable: true,dataIndex :'brithday', renderer:Ext.util.Format.dateRenderer('Y年m月d日'), editor:new Ext.form.DateField() }, { header: "姓名", width: 100, sortable: true,dataIndex :'name'}, { header: "年龄", width: 100, sortable: true,dataIndex :'age', renderer:age, editor:new Ext.form.NumberField({ allowBlank:false }) }, { header: "Email", width: 120, sortable: true,dataIndex :'email', editor:new Ext.grid.GridEditor(new Ext.form.TextField({ vtype:"email" }) ) } ]); var store = new Ext.data.GroupingStore({ data :data, reader : new Ext.data.ArrayReader({id:"id"},fields) }); var gridForm = new Ext.FormPanel({ id: 'user_info', applyTo:Ext.getBody(), frame: true, autoHeight:true, labelAlign: 'left', title: '员工信息表', bodyStyle:'padding:5px', width: 600, items:[new Ext.grid.GridPanel({ title:"人员信息列表", width:600, autoHeight:true, frame:true, cm:cm, store:store, /*sm:new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { Ext.getCmp("user_info").getForm().loadRecord(rec); } } }), */ listeners: { viewready: function(g) { g.getSelectionModel().selectRow(0); } // Allow rows to be rendered. }, view:new Ext.grid.GroupingView({ hideGroupedColumn : true, showGroupsText :"分组显示", groupByText:"使用当前字段排序", forceFit :true, columnsText :"隐藏/显示字段", sortAscText:"升序排列", sortDescText:"降序排列" }) }),{ xtype: 'fieldset', labelWidth: 150, title:'加载grid信息内容', defaultType: 'textfield', autoHeight: true, items:[{ fieldLabel: 'ID', name :'id', anchor : '55%' },{ fieldLabel: '性别', name :'sex', anchor : '55%' },{ fieldLabel: '生日', name :'brithday', anchor : '55%' },{ fieldLabel: '年龄', name :'age', anchor : '55%' },{ fieldLabel: '邮箱', name :'eamil', anchor : '55%' }] }] }); });
相关文章推荐
- extjs中form与grid交互数据(record)的方法
- extjs中form与grid交互数据(record)的方法
- extjs中form与grid交互数据(record)的方法使用
- ExtJs4 中 获取grid列表数据绑定到form表单
- ExtJS的FormPanel中的组件使用load加载远程的JSON数据的方法
- extjs form.load()加载服务端数据
- jquery插件loadForm.js 编辑页表单默认数据加载
- 在easyUI中把form表单转换成json数据利用datagrid的load方法实现条件查询
- Ext JS4 学习笔记之发送表单(Form)时也将表单下的表格(Grid)数据一同发送的方法
- easyUi load方法重新加载表单的数据
- Extjs创建form表单以及绑定动态数据到grid
- Form表单只提交数据而不进行页面跳转的方法
- EASYUI TREEGRID异步加载数据实现方法
- extjs 清空表单数据万能方法
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
- PHP通过get方法获得form表单数据方法总结
- Extjs的form表单中,如何不提交数据
- 关于ie中easyui form组件load事件无法多次加载数据
- Form表单只提交数据而不进行页面跳转的方法
- ExtJs 备忘录(3)—— Form表单(三) [ 数据验证 ]