PDA

View Full Version : MVC RowEditor Cancel Event



ErnestoR
9 Feb 2012, 3:10 PM
Hello Forum,

I have a simple Grid Panel with the Roweditor plugin and I'm trying to listen to the event canceledit from a controller but it isn't firing.

GridPanel


Ext.define('Mx.view.grupoListGridPanel',{
extend: 'Ext.grid.Panel',
alias: 'widget.grupoListGridPanel',
title: 'Grupo',
store: 'grupo.queryGrupoAll',
plugins: [{
ptype: 'rowediting',
clicksToEdit: 2,
autoCancel: false
}],
columns: [
{
header: 'ID',
dataIndex: 'id'
},
{
header: 'Nombre',
dataIndex: 'nombre',
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{
header: 'Descripcion',
dataIndex: 'descripcion',
editor: {
xtype: 'textfield',
allowBlank: false
}
}
]
});


Controller


Ext.define('Mx.controller.prospectoController',{
extend: 'Ext.app.Controller',
models:[
'grupo.grupoAll'
],
stores:[
'grupo.queryGrupoAll'
],
views: [
'grupoListGridPanel'
],
init: function() {
this.control({
'grupoListGridPanel' :{
edit: this.afterGrupoEdit,
canceledit: this.onCancelGrupoEdit
}
});
},

afterGrupoEdit: function(grid){
console.log(grid);
console.log('after edit');
this.getGrupoQueryGrupoAllStore().sync();
},

onCancelGrupoEdit: function(){
console.log('cancel');
}
});


The wierd thing is that the event edit IS firing and according to the documentation its fired by the plugin but it won't work with the event canceledit.

Am I doing something wrong??

vietits
9 Feb 2012, 3:59 PM
What version of Ext do you use?

With 4.0.2a: the rowEditor plugin won't fire 'cancelEdit' event at all.
With 4.0.7: the plugin fires 'cancelEdit' event but the grid won't relay it so your controller can't not catch it.
4.1.0-b1: the plugin fires 'cancelEdit' event and the grid relay this event so your controller can catch it.

ErnestoR
9 Feb 2012, 4:17 PM
What version of Ext do you use?
I'm using Ext 4.0.7
So its a bug ok.
I've managed to do a little work around in the plugin configuration:


plugins: [{
ptype: 'rowediting',
clicksToEdit: 2,
autoCancel: false,
listeners: {
canceledit: function(view){
view.grid.fireEvent('canceledit', this);
}
}
}]


Thanks!!! :)

igordiuk
8 Sep 2012, 1:30 PM
Thank's for this post!