1

当我试图覆盖 Ext formpanel 时,如何调用 formpanel.getForm() 方法?

commentsForm = Ext.extend(Ext.form.FormPanel, {
    frame: true,
    initComponent: function() {
        var config = {
        frame : true,
        autoScroll : true,
        labelWidth : 150,
        autoWidth : true,
        labelPad : 20,
        waitMsgTarget: true,
        bodyStyle:'padding:0px 15px 15px 15px',
        items: [{
            xtype : 'fieldset',
            title : 'Write Comment',
            anchor : '100%',
            defaults : {
                selectOnFocus: true,
                msgTarget: 'side',
                xtype: 'textfield',
                width : 200
            },
            items : [{
                xtype : 'textarea',
                name : 'comment',
                allowBlank : false
            }, {
                name : 'added_by',
                allowBlank : false
            }, {
                xtype : 'myndatefield',
                name : 'added_at',
                allowBlank : false,
                value : new Date()
            }]
        }],
        buttons: [{
            text: 'Add',
            handler : function() {
                // TODO 
                var classForm = this.getForm();

                console.log(this.getForm());

                if (classForm.isValid()) {
                    console.log(classForm.findField("name"));
                }
                Ext.WindowMgr.hideAll();
            }
        }, {
            text: 'Cancel',
            handler : function() {
                Ext.WindowMgr.hideAll();
            }
        }]
    };

    Ext.apply(this, Ext.apply(this.initialConfig, config));
    myn.commentsForm.superclass.initComponent.apply(this);

}

});

4

1 回答 1

0

首先在您的代码中,您正在扩展而不是覆盖......

commentsForm.getForm()是一种在您的 FormPanel 中访问 BasicForm 的方法,如果您放在var非常开始的位置,但是您的代码在名称空间方面令人困惑: myn.commentsForm.superclass.initComponent.apply(this);

于 2011-02-22T04:16:31.420 回答