0

formBase に動的に作成されたすべての UI コントロールが含まれている画面があります。カード レイアウトを使用し、ビューを切り替えています。たまたま、カードが切り替わるたびに (画面が表示されるたびに) formBase を実行する必要がありました。

それを実現するために、フォームの beforeshow リスナーを使用しました。しかし、うまくいきません。以下は私のコードです。

var formBase = new Ext.form.FormPanel({
        scroll: 'vertical',
        ui: 'round',
        items: [fieldSet, {
            xtype : 'fieldset',
            items : [ item1, item2, item3]
            ]
        }],
         listeners: {
            beforerender: function(ele) {
               console.log(" Screen before render");
               initScreenComps()
            },

            beforeshow: function(ele) {
                console.log(" screen before show");

            }
        }
    });

編集:1

ビューポートを変更するためのメソッドを公開するviewport.jsファイルがあります。以下は Viewport.js のコードです。それでも効果はありません。plsは提案します。

MyApp.views.Viewport = Ext.extend(Ext.Panel, {
    fullscreen: true,
    layout: 'card',
    initComponent: function() {
        Ext.apply(this, {

            items: [
                { xtype: 'MyApp.views.view1', id: 'view1' },
                { xtype: 'MyApp.views.view2', id: 'view2' },
                { xtype: 'MyApp.views.view3', id: 'view3' },
                { xtype: 'MyApp.views.view4', id: 'view4' },
                { xtype: 'MyApp.views.view5', id: 'view5' }             
            ],
        listeners:{
           beforecardswitch:function(newCard, oldCard, index, animated){
                 //do something...
               console.log(" Card switched"  + " New " + newCard + " OLD : " + oldCard + " index + " index);
           }
        }
        }
        );
        MyApp.views.Viewport.superclass.initComponent.apply(this, arguments);
    },

    // used for changing view port of application
    reveal: function(target) {      
        this.setActiveItem(MyApp.views[target],{ type: 'slide', direction: 'right' }
        );
    }
});

そして今、ボタンクリックイベントでコントローラーからview2を呼び出しています。

MyApp.views.viewport.reveal('view2');
4

2 に答える 2

1

「beforeactivate」または「activate」イベントリスナーを使用するのが最善だと思います。これらのイベントは、カード レイアウトがこのアイテムをアクティブなアイテムとして設定するたびに発生します。したがって、コードは次のようになります。

var formBase = new Ext.form.FormPanel({
        scroll: 'vertical',
        ui: 'round',
        items: [fieldSet, {
            xtype : 'fieldset',
            items : [ item1, item2, item3]
            ]
        }],
         listeners: {
            beforeactivate: function(panel) {
               console.log(" Screen before render");
               initScreenComps()
            }
        }
    });
于 2011-11-03T13:21:53.683 に答える
0

beforecardswitch代わりにイベントをリッスンする必要があります。例えば

listeners:{
   beforecardswitch:function(newCard, oldCard, index, animated){
 //do something...
   }
}
于 2011-11-03T12:04:01.630 に答える