1
votes

I am trying to implement the beforeedit listener in my table. I would like to do some checking before a user is allowed to do something to the cell.

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

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

When I try and edit a cell, this alert(..) is not called. Why is this not going into the listener? If I look on the internet there are plenty of examples of Ext.grid.Panel with beforeedit.

Anyway I tried to extend with Ext.grid.EditorGridPanel instead.

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

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

Now I get an obscure error in typical extjs fashion :

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

What am I doing wrong? And why should you use EditorGridPanel over normal grid? Is it for the Excel like properties?

EDIT : yes. sorry i forgot to put beforeedit in 'listeners'. Question still stands as is though.

1

1 Answers

1
votes
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/ - working fiddle

You miss a few things:

Grid has NO 'beforeedit' event. You need to add an editor to your grid Example is here

Events should be put in the "listeners" object

(having big troubles with stackoverflow markup)