2014-09-29 165 views
0

我試圖在我的表中實現beforeedit監聽器。我想在用戶被允許爲單元格做某事之前做一些檢查。在網格上實現preedit監聽器

Ext.define('myGrid', { 
     extend: 'Ext.grid.Panel', 

     listeners: { 
      beforeedit: function (e) { 
      alert('hi') 
      }, 
     } 

當我嘗試和編輯單元格,這警報(..)不叫。爲什麼這不會進入聆聽者?如果我在網上看,有很多ext.grid.Panel和beforeedit的例子。

無論如何,我試圖擴展與而不是Ext.grid.EditorGridPanel

Ext.define('myGrid', { 
     extend: 'Ext.grid.EditorGridPanel', 

     listeners: { 
      beforeedit: function (e) { 
      alert('hi') 
      } 
     } 

現在我得到了典型的ExtJS的時尚一個不起眼的錯誤:

http://jsfiddle.net/S8Tgm/13/

我在做什麼錯?爲什麼你應該在正常的網格上使用EditorGridPanel?這是Excel的屬性?

編輯:是的。對不起,我忘了提前在'聽衆'。問題依然存在。

回答

1
listeners: { 
    beforeedit: function (e) { 
     alert('hi') 
    } 
}, 
plugins: [ 
    Ext.create('Ext.grid.plugin.RowEditing', { //or even better - use ptype here 
    clicksToEdit: 1 
})], 

http://jsfiddle.net/S8Tgm/12/ - 工作小提琴

你錯過了幾件事情:

電網沒有 'beforeedit' 事件。你需要一個編輯器添加到您的網格Example is here

活動應放在「聽衆」對象

(具有計算器標記帶來很大麻煩)

+0

有沒有這樣做,而不RowEditing插件的任何方式? – 2014-09-29 16:19:52

+0

我有點缺少這裏的意思..你可以改用CellEditor。點擊複選框時是否需要觸發事件?沒有實際的行編輯?這是網格上的sencha文檔:[http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel](http://docs.sencha.com/extjs/4.2.2 /#!/api/Ext.grid.Panel) - 選中「事件」下拉菜單查看所有可用的網格事件(沒有任何插件) – 2014-09-29 16:24:22

+0

ahhh ok。編輯器必須添加爲插件 – 2014-09-29 16:28:57