3

私は 1 つのパネルでビューを作成し、その中に「ようこそ」と「contactus」という 2 つのフォーム パネルが含まれています。「ようこそ」にはボタンが含まれており、「onclick」イベントが含まれています。そのボタンを押すと、「ようこそ」 " フォームで、"contactus" フォームを表示する必要があります。コントローラーを追加し、ボタンにイベントを追加しました。今私の問題は、パネルから個々のフォームを選択する方法と、コントローラーでこれらの個々のフォームを参照する方法です。コントローラー参照には、「selector」、「xtype」、「ref」などのフィールドがあります。これらのフィールドを埋めるには助けが必要です.私を助けてくれる人に感謝します:)

'/*

* ファイル: app/view/contactus.js * * このファイルは Sencha Architect バージョン 2.2.2 によって生成されました。* http://www.sencha.com/products/architect/ * * このファイルは、独立したライセンスの下で Ext JS 4.2.x ライブラリを使用する必要があります。* Sencha Architect のライセンスには、Ext JS 4.2.x のライセンスは含まれていません。詳細については、http://www.sencha.com/licenseを参照するか、license@sencha.com までお問い合わせください。* * このファイルは、プロジェクトを保存するたびに自動生成されます。* * このファイルを手で編集しないでください。*/

Ext.define('MyApp.view.contactus', {
extend: 'Ext.panel.Panel',
alias: 'widget.contactus',

height: 724,
width: 479,

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {
        items: [
            {
                xtype: 'welcome',
                frame: true,
                height: 250,
                html: 'Thank you for visiting our site! We welcome your feedback;       itemId: 'welcomeid',
                width: 400,
                layout: {
                    align: 'middle',
                    type: 'hbox'
                },
                bodyPadding: 10,
                title: 'Welcome',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        flex: 1,
                        dock: 'top',
                        items: [
                            {
                                xtype: 'button',
                                itemId: 'contactusId',
                                margin: '0 0 50 50',
                                maxWidth: 70,
                                width: 70,
                                allowDepress: false,
                                preventDefault: false,
                                text: 'MyButton'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'contactus',
                frame: true,
                height: 250,
                hidden: true,
                itemId: 'contactid',
                margin: '10 0 0 0',
                width: 400,
                bodyPadding: 10,
                title: 'Contact Us ',
                tools: [
                    {
                        xtype: 'tool'
                    }
                ],
                items: [
                    {
                        xtype: 'container',
                        layout: {
                            align: 'stretch',
                            type: 'hbox'
                        },
                        items: [
                            {
                                xtype: 'textfield',
                                flex: 1,
                                fieldLabel: 'Name',
                                labelWidth: 35,
                                allowBlank: false,
                                emptyText: 'FirstName'
                            },
                            {
                                xtype: 'textfield',
                                margin: '0 0 0 5',
                                width: 45,
                                fieldLabel: ''
                            },
                            {
                                xtype: 'textfield',
                                margin: '0 0 0 10',
                                width: 145,
                                allowBlank: false,
                                emptyText: 'LastName'
                            }
                        ]
                    },
                    {
                        xtype: 'textfield',
                        anchor: '100%',
                        padding: '10 0 0 0',
                        fieldLabel: 'Email',
                        labelWidth: 50,
                        allowBlank: false,
                        vtype: 'email',
                        vtypeText: 'Enter a valid email Id!!'
                    },
                    {
                        xtype: 'container',
                        items: [
                            {
                                xtype: 'toolbar',
                                id: '',
                                margin: '0 0 0 280',
                                items: [
                                    {
                                        xtype: 'button',
                                        itemId: 'saveId',
                                        text: 'Save'
                                    },
                                    {
                                        xtype: 'button',
                                        itemId: 'cancelId',
                                        text: 'Cancel'
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    });

    me.callParent(arguments);
}

});

Ext.define('MyApp.controller.MyController', { 拡張: 'Ext.app.Controller',

refs: [
    {
        autoCreate: true,
        ref: 'welcome',
        selector: 'welcome',
        xtype: ''
    },
    {
        ref: 'contactus',
        selector: 'contactus'
    }
],

onButtonClick: function(button, e, eOpts) {

    debugger;
    var form=this.getContactus();
    var form1=this.getWelcome();
    form.show();
    //debugger;
    //form1.setDisabled(true);
    //form1.disable(true);
    form1.hide();

},

onSaveButtonClick1: function(button, e, eOpts) {
    var form=this.getContactus();
    var form1=this.getWelcome();
    form.hide();
    form1.show();

},

init: function(application) {
    this.control({
        "button#contactusId": {
            click: this.onButtonClick
        },
        "button#saveId": {
            click: this.onSaveButtonClick1
        }
    });
}

});'

4

1 に答える 1

0

コントローラーから up() または down() の選択を試すことができます。以下は、ソース コードのコード スニペットの例です。

onButtonClick: function(button, e, eOpts) {

    debugger;
    var thisView = this.getView();
    var form= thisView.down('contactus');
    var form1=thisView.down('welcome');
    form.show();
    //debugger;
    //form1.setDisabled(true);
    //form1.disable(true);
    form1.hide();

}
于 2015-08-05T03:33:02.020 に答える