我在Sencha Touch 2中有一个字段集,如下所示:
{
id:'contactForm',
xtype: 'fieldset',
title: 'Information',
items: [
{
xtype: 'textfield',
label: 'First Name',
placeHolder: 'Your First Name',
name:'firstName',
id:'firstName',
},
{
xtype: 'textfield',
label: 'Last Name',
placeHolder: 'Your Last Name',
name:'lastName'
},
{
xtype: 'emailfield',
label: 'Email',
placeHolder: 'email@example.com'
},
{
xtype: 'button',
height: 37,
style: 'margin-left:35%',
width: 100,
iconAlign: 'center',
text: 'Submit',
action:'ContactSubmit'
},
{
xtype: 'hiddenfield',
id: 'HNumberOfBedRoom',
value:'2'
},
{
xtype: 'hiddenfield',
id: 'HPetFriendlyId',
value:'2'
}
]
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我有以下内容:
refs: {
contactForm: '#contactForm'
}
我可以通过使用来回溯价值
var frmItems=this.getContactForm().getItems();
console.log(frmItems.items[1]._value);
这工作正常,但我想检索像这样的值
frm.get('name/id of component')
有没有办法实现这个目标?
小智 8
使用Ext.form.Panel作为主容器.
示例代码段
Ext.define('App.view.ContactForm',
{
extend : 'Ext.form.Panel',
xtype : 'contactform',
id : 'contactForm',
config : {
items : [
{
xtype : 'fieldset',
items : [
{
{
xtype: 'textfield',
label: 'First Name',
placeHolder: 'Your First Name',
name:'firstName',
},
]
}
});
Run Code Online (Sandbox Code Playgroud)
在你的控制器中
refs:{contactForm:'#contactForm'}
那么在你的功能中你可以做到
this.getContactForm().getValues().firstName
Run Code Online (Sandbox Code Playgroud)
(使用字段的名称值)
要么
var vals = this.getContactForm().getValues();
vals.firstName;
Run Code Online (Sandbox Code Playgroud)
如果绝对可以帮助它,请避免在顶层使用Ext.getCmp()或平面Ext.get().如果您正在构建自定义控件,则可能必须使用这些控件,否则您会对自己造成太大的困难.
| 归档时间: |
|
| 查看次数: |
9199 次 |
| 最近记录: |