微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

extjs – 如何从Ext表单中获取值

实际上我有一个ExtJs脚本来创建窗口,下面有一个Window.
var frmAccount = Ext.create('Ext.form.Panel',{
    bodyPadding: 5,frame  : true,items    :[
    {
        xtype       : 'textfield',fieldLabel  : 'Account Number',name        : 'accountNum'
    },{
        xtype       : 'textfield',fieldLabel  : 'Company',name        : 'company'
    },fieldLabel  : 'Office',name        : 'office'
    },{
        xtype       : 'textareafield',fieldLabel  : 'Address',name        : 'address',width       : 350
    },fieldLabel  : 'City',name        : 'city'
    },fieldLabel  : 'Country',name        : 'nation'
    }]
});

var winAddAccount = Ext.create('widget.window',{
    id     : 'addAccount',title  : 'Filter Record',width  : 400,height : 300,modal  : true,closeAction    : 'hide',items  : frmAccount,layout : 'fit',bodyPadding: 5,buttons:[
    {
        text    : 'Find',handler: function(){
            //console.log(form value);
        }
    },{
        text    : 'Cancel',handler: function(){
            winAddAccount.hide();
        }
    }
    ]
});

我只想在点击“查找”按钮后从表单中获取值.
但是在点击“查找”按钮后,我不知道从表单中获取值.
希望我可以在处理程序上看到console.log脚本的值.
请帮助我解决或提出一个想法.
谢谢.

解决方法

试试这个
text    : 'Find',handler: function(btn){
    var win = btn.up('window'),form = win.down('form');
    console.log(form.getForm().getValues());
}

此外,我建议您浏览一下sencha提供的tutorials,并查看API,其中还包含大量示例

要仅获取特定字段的值(此示例假定该字段存在!)

text    : 'Find',form = win.down('form');
    console.log(form.getForm().findField('NamePropertyValue').getSubmitValue() /*or call getSubmitData() or just getValue()*/);
}

原文地址:https://www.jb51.cc/html/227926.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐