【问题标题】:How to get form on toolbar in gridpanel Extjs如何在gridpanel Extjs的工具栏上获取表单
【发布时间】:2013-06-21 02:52:34
【问题描述】:

我在网格面板中有 tbar。我的示例代码如

    tbar:[
            {
                xtype: 'form',
                items: [{
                    xtype: 'filefield',
                    name: 'filefor',
                    labelWidth: 50,
                    allowBlank: false,
                    buttonConfig: {
                        text: 'up...'
                    }
                }]
            }
            ,{
                text: 'add',
                handler:function(){
                        var form = this.up('form').getForm(); // not working
                        form.submit({}); // not working
                }
             }
   ]

我无法提交表单。我该怎么做,非常感谢:)。

【问题讨论】:

    标签: extjs extjs4 extjs4.1 toolbar


    【解决方案1】:

    formadd 按钮的兄弟。您可能想使用 .prev 而不是 .up 来访问表单

    这是有效的 sn-p

    Ext.require([
        'Ext.form.*',
        'Ext.tip.*']);
    
    Ext.onReady(function () {
    
        Ext.QuickTips.init();
        var f = Ext.create('Ext.form.Panel', {
            renderTo: Ext.getBody(),
            bodyStyle: 'padding: 5px 5px 0 5px;',
            defaults: {
                xtype: 'textfield',
                anchor: '100%',
            },
            html:'text',
            tbar: [{
                xtype: 'form',
                items: [{
                    xtype: 'filefield',
                    name: 'filefor',
                    labelWidth: 50,
                    allowBlank: false,
                    buttonConfig: {
                        text: 'up...'
                    }
                }]
            }, {
                text: 'add',
                handler: function () {
                  //var form = this.prev('form').getForm(); // working at extjs4.0.2a
                   var form =this.ownerCt.down('form').getForm();// working at extjs 4.2.0
                   form.submit({});
                }
            }]
    
        });
    });
    

    对于现场演示,here it is the jsfiddle link

    【讨论】:

      【解决方案2】:
      var form = this.up('form').getForm(); // not working
                          form.submit({}); // not working
      change to:
      this.ownerCt.down('form').getForm();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-15
        • 1970-01-01
        • 2022-08-19
        • 1970-01-01
        相关资源
        最近更新 更多