Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch Sencha Touch 2表格_Sencha Touch_Sencha Touch 2 - Fatal编程技术网

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()
。编辑我的答案。这很有效。谢谢你的解释。为什么投否决票?想评论一下吗。。!