2011-10-23 8 views
0

この例を考えてみましょう: http://docs.sencha.com/ext-js/4-0/#!/example/grid/binding-with-classes.html コントローラーで 'selectchange'イベントを処理します。次のコードのように:ExtJSグリッドイベント処理

Ext.define('AM.controller.Users', { 
    init: function() { 
     this.control({ 
      'useredit button[action=save]': { 
       click: this.updateUser 
      } 
     }); 
    }, 

    updateUser: function(button) { 
     console.log('clicked the Save button'); 
    } 
}); 

どうすればよいですか? おかげ

答えて

1

グリッド:

Ext.define('MyApp.view.ui.MyGridPanel', { 
    extend: 'Ext.grid.Panel', 
    alias:'widget.mygridpanel', 

    height: 250, 
    width: 400, 
    title: 'My Grid Panel', 

    initComponent: function() { 
     var me = this; 

     Ext.applyIf(me, { 
      columns: [ 
       { 
        xtype: 'gridcolumn', 
        dataIndex: 'string', 
        text: 'String' 
       }, 
       { 
        xtype: 'numbercolumn', 
        dataIndex: 'number', 
        text: 'Number' 
       }, 
       { 
        xtype: 'datecolumn', 
        dataIndex: 'date', 
        text: 'Date' 
       }, 
       { 
        xtype: 'booleancolumn', 
        dataIndex: 'bool', 
        text: 'Boolean' 
       } 
      ], 
      viewConfig: { 

      } 
     }); 

     me.callParent(arguments); 
    } 
}); 

あなたのコントローラがある:

Ext.define('AM.controller.Users', { 
    init: function() { 
     this.control({ 
      'useredit button[action=save]': { 
       click: this.updateUser 
      }, 
      'mygridpanel':{ 
       selectionchange:this.changeselection 
      } 
     }); 
    }, 

    changeselection:function(selectionModel,record){ 
     console.log(record); 
    }, 

    updateUser: function(button) { 
     console.log('clicked the Save button'); 
    } 
});