2013-12-20 17 views
0

這是我的網格列KEYUP,按鍵事件不火的ExtJS的GRD列

MyColumn3Ui = Ext.extend(Ext.grid.NumberColumn, { 
    constructor: function(cfg) { 
     cfg = cfg || {}; 
     MyColumn3Ui.superclass.constructor.call(this, Ext.apply({ 
      dataIndex: 'ID', 
      header: 'name', 
      sortable: true, 
      width: 75, 
      align: 'right', 
      id: 'name_col', 
      editor: { 
       xtype: 'numberfield', 
       name: 'ID', 
       decimalPrecision: 0, 
       allowDecimals: false, 
       enableKeyEvents: true, 
       allowBlank: false, 
       maxLength: 5, 
       id: 'col_id' 
      } 
     }, cfg)); 
    } 
}); 

這是我嘗試火KEYUP和按鍵事件

this.col = Ext.getCmp('col_id'); 
this.col.blur = blurFun .createDelegate(this, [this.col, 4,""]); 
this.col.keyup = keyupFun.createDelegate(this, [this.col, 4,""]); 
this.col.keypress = keypressFun .createDelegate(this, [this.col, 4,""]); 

blurFun = function(txtField, length, nextField) { 
    alert('blur'); 
} 
keyupFun= function(txtField, length, nextField) { 
    alert('keyup '); 
} 
keypressFun = function(txtField, length, nextField) { 
    alert('keypress'); 
} 

當我的名字列中單擊只顯示blur警報。其他事件在我可編輯的ExtJs網格中不會觸發。我想爲火KEYUP,在我的網格列

+2

你必須添加「enableKeyEvents:真正的」配置您的文本字段用於綁定的關鍵事件。 –

+0

感謝您的幫助我檢查enableKeyEvents:true作爲我的新更改代碼它不適用於我 – Duleep

回答

0

按鍵事件,事件偵聽器添加到組件是什麼,使用on功能:

this.col.on({ 
    'blur': function(field) { 
     alert('blur'); 
    }, 
    scope: this 
}); 
+0

我可以使用我的代碼獲得'blur'警報但其他關鍵事件不適用於我 – Duleep

+0

因爲您已**覆蓋**用你的代碼模糊textfield的功能。如果你想使用事件監聽器(你應該!),使用我建議的代碼。您可以對所提到的所有事件使用相同的語法,只需更改事件名稱即可。 – matt

0

山坳模型沒有像事件KEYUP。 keyup事件火在編輯

this.col.keyup = keyupFun.createDelegate(this, [this.col, 4,""]); 

變化

this.col.editor.keyup = keyupFun.createDelegate(this, [this.col.editor, 4,""]); 
相關問題