2

グリッド MVC にリスナーを追加できる正確な場所を知りたいです。

私がこれを行うと、何も起こりません:

Ext.define('myApp.view.reslist' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.reslist',
    store : 'resStore',
    listeners: {
          activate: {
            fn: function(e){ 
                console.log('reslist panel activated');
                  }
            }
           },
    dockedItems: [{
           xtype: 'pagbar',
           store: 'resStore',
           dock: 'top',
           displayInfo: true
       }],
       ..... rest of grid configs

クリックイベントで動作します:

listeners: {
          activate: {
            fn: function(e){ 
                console.log('reslist panel clicked');
                 }
          }
           }

注:コントローラーの初期化はまだ空です:

Ext.define('myApp.controller.resControl', {
    extend: 'Ext.app.Controller',

    stores: ['resStore'],

    models: ['resModel'],

    views: ['reslist','pagbar'],

    init: function() {

            // nothing here 
        }
});
4

1 に答える 1

3

ビューのアクションとイベントは、適切なコントローラーに入ります。私のビューには、コンポーネントの構築とレンダリングに使用される構成と必要なメソッドのみが含まれています。すべてのイベント ハンドラー、ボタンのアクションなどはコントローラーにあります。私のコントローラーは次のようになります。

Ext.define('myApp.controller.resControl', {
    extend: 'Ext.app.Controller',
    stores: ['resStore'],
    models: ['resModel'],
    views: ['reslist','pagbar'],
    init: function() {

        this.control({
            'reslist' : {
                activate: function(e) { 
                        alert('reslist panel activated');
                }               
            }
        });
    }
});

activate イベントは、タブ パネル表示を使用する場合にのみ、パネルで呼び出されることに注意してください。タブをクリックしてパネルがアクティブになると、イベントが呼び出されます。

于 2011-05-22T05:39:43.987 に答える