Search code examples
extjsextjs3

Forcing change event on grid


We have a gridpanel in ExtJs 3.2,with a text field as an editor on one of the columns:

var psp_config= {
store:ProjectSponsorView.s_store,
.....
tbar: new Ext.Toolbar({     
... 
}),
......
columns: [
....
{header: '% Contribution', 
  renderer:  Ext.util.Format.numberRenderer('000.00'),
  editor: new Ext.form.TextField({
         listeners: {
            'change' : function (field, newValue, oldValue) {
                ........
            }
         }
      })

}

We have a situation wherein the change event of teh editor does not get fired if the user submits the form, while the focus is still within the editor/column.
This causes the stale data to be submitted for that particular column.
How do we forcibly have the gridpanel/column/editor to register/accept the changed value in such a case?


Solution

  • I presume you use EditorGridPanel? If so, maybe attach to its afteredit event:

    enter image description here

    Config would look something like this:

    ......
    columns: [
    ....
      {
        header: '% Contribution', 
        renderer:  Ext.util.Format.numberRenderer('000.00'),
        editor: new Ext.form.TextField({})
      }
    ],
    listeners: {
      afteredit: function(e) {
        //handle changes here
      }
    }