今儿心情不太好,多敲几行代码消消气~
来源:互联网 发布:嘉鱼网络推广经理招聘 编辑:程序博客网 时间:2024/04/30 02:04
Ext.form.Panel获取其组件的值:
API里清晰可见
Ext.create('Ext.form.Panel', { title: 'Simple Form', bodyPadding: 5, width: 350, // The form will submit an AJAX request to this URL when submitted url: 'save-form.php', // Fields will be arranged vertically, stretched to full width layout: 'anchor', defaults: { anchor: '100%' }, // The fields defaultType: 'textfield', items: [{ fieldLabel: 'First Name', name: 'first', allowBlank: false },{ fieldLabel: 'Last Name', name: 'last', allowBlank: false }], // Reset and Submit buttons buttons: [{ text: 'Reset', handler: function() { this.up('form').getForm().reset(); } }, { text: 'Submit', formBind: true, //only enabled once the form is valid disabled: true, handler: function() { var form = this.up('form').getForm(); if (form.isValid()) { console.log(form.getValues()); /*form.submit({ success: function(form, action) { Ext.Msg.alert('Success', action.result.msg); }, failure: function(form, action) { Ext.Msg.alert('Failed', action.result.msg); } });*/ } } }], renderTo: Ext.getBody()});
如你所见,既然有getValues()方法,那就有setValues()方法啦...
var formPanel = Ext.create('Ext.form.Panel', { title: 'Simple Form', bodyPadding: 5, width: 350, // The form will submit an AJAX request to this URL when submitted url: 'save-form.php', // Fields will be arranged vertically, stretched to full width layout: 'anchor', defaults: { anchor: '100%' }, // The fields defaultType: 'textfield', items: [{ fieldLabel: 'First Name', name: 'first', allowBlank: false },{ fieldLabel: 'Last Name', name: 'last', allowBlank: false }], // Reset and Submit buttons buttons: [{ text: 'Reset', handler: function() { this.up('form').getForm().reset(); } }, { text: 'Submit', formBind: true, //only enabled once the form is valid disabled: true, handler: function() { var form = this.up('form').getForm(); if (form.isValid()) { console.log(form.getValues()); /*form.submit({ success: function(form, action) { Ext.Msg.alert('Success', action.result.msg); }, failure: function(form, action) { Ext.Msg.alert('Failed', action.result.msg); } });*/ } } }], renderTo: Ext.getBody()});formPanel.getForm().setValues({first:'Haw',last:'King'});
Ext.create('Ext.data.Store', { storeId:'simpsonsStore', fields:['name', 'email', 'phone'], data:{'items':[ { 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" }, { 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" }, { 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" }, { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" } ]}, proxy: { type: 'memory', reader: { type: 'json', root: 'items' } }});var panel = Ext.create('Ext.grid.Panel', { title: 'Simpsons', store: Ext.data.StoreManager.lookup('simpsonsStore'), columns: [ { header: 'Name', dataIndex: 'name' }, { header: 'Email', dataIndex: 'email', flex: 1 }, { header: 'Phone', dataIndex: 'phone' } ], height: 200, width: 400, renderTo: Ext.getBody()});panel.on('itemclick',function(self,records){ console.log(records.data);});
将得到的值对象,调用用formPanel的getForm().setValues()方法。
-----------------------------------------------------------------------------------------------
这是在API里拔搭的....
稍等上一段代码,扩展formPanel的一个方法,getCompoentByName()。
代码很清晰了,就不细说。
- 今儿心情不太好,多敲几行代码消消气~
- 今儿心情不太好,多敲几行代码消消气~续之二
- 心情不太好
- 心情还是不太好
- 心情不错,薪情却不太好
- 今天心情不太好
- 今儿写了点儿代码
- 随便写点什么,心情不太好
- 我是个年轻人,我心情不太好
- 我自己觉得不太好的代码一览:
- 消消乐代码原理及工程链接
- 自制游戏 消消乐 代码 css
- 自制游戏 消消乐 代码 my.js
- 气
- 气
- [Android] 开心消消乐代码(写的比较简单)
- 阿里云天气预报接口代码
- 不太好玩
- 算法导论 2-3
- 96
- class与struct
- 添加wcf服务引用后无法使用
- STM32 keilC 局部变量和全局变量
- 今儿心情不太好,多敲几行代码消消气~
- ubuntu的virtualbox安装使用
- C++ 读书笔记之 重载 Overloading
- 容器内存释放问题(STL新手笔记)
- 技术网站保存
- django south做数据库迁移
- 使用 -Wl,rpath设置动态库的搜索路径
- Sybase 相关信息
- 使用JDBC进行批处理