Sencha touch Sencha Touch 2表格
我有一个弹出窗口,其中有一个表单文本字段。如何访问文本字段?以下是我的尝试:Sencha touch Sencha Touch 2表格,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我有一个弹出窗口,其中有一个表单文本字段。如何访问文本字段?以下是我的尝试: function foo(){ bar = Ext.Viewport.add({ xtype: 'panel', scrollable: true, centered: true, width: 400, height: 300, items:[{ xtype: 'textfield', name: 'name',
function foo(){
bar = Ext.Viewport.add({
xtype: 'panel',
scrollable: true,
centered: true,
width: 400,
height: 300,
items:[{
xtype: 'textfield',
name: 'name',
label: 'Name'
}, {
docked: 'bottom',
xtype: 'titlebar',
items:[{
xtype: 'button',
ui: 'normal',
text: 'Send',
go: 'testsecond',
handler:function(){
alert(bar.getValues().name);
}
}]
}]
});
}
没有。你不必这样做。设置
xtype:“panel”
将阻止您使用form.getValues()
方法访问表单值
相反,请按以下方法操作
将面板X类型设置为formpanel
见下文:
bar = Ext.Viewport.add({
xtype: 'formpanel',
scrollable: true,
centered: true,
width: 400,
height: 300,
items:[{
xtype: 'textfield',
name: 'name',
label: 'Name'
}, {
docked: 'bottom',
xtype: 'titlebar',
items:[{
xtype: 'button',
ui: 'normal',
text: 'Send',
go: 'testsecond',
handler:function(){
Ext.Msg.alert("Name: "+bar.getValues().name);
}
}]
}]
});
您的输出应该是:
您不需要在此处调用
getCmp
。您已经使用bar
变量对表单进行了引用。@rdougan:Oops。我错过了那个参考资料。是的,那么就不需要调用getCmp()
。编辑我的答案。这很有效。谢谢你的解释。为什么投否决票?想评论一下吗。。!