PDA

View Full Version : How to update a cell with cellediting in override onEditComplete?



21 Feb 2013, 12:21 PM
I'm trying to get my code to use properly use the CellEditing override to only update the cell that was changed. This is working fine. Just cannot get the cell to update to the new value.

The issue is that the model I have, by calling record.set(), it send all of the cell (columns) which I don't want to that due to how the grid is setup.

What I'm trying to find is in the Ajax success callback is what do I do to get the cell to use the updated value to display correctly?


Ext.override(Ext.grid.plugin.CellEditing, {
onEditComplete : function(ed, value, startValue) {
var me = this,
grid = me.grid,
activeColumn = me.getActiveColumn(),
sm = grid.getSelectionModel(),
record;

if (activeColumn) {
record = me.context.record;

me.setActiveEditor(null);
me.setActiveColumn(null);
me.setActiveRecord(null);

if (!me.validateEdit()) {
return;
}

// Only update the record if the new value is different than the
// startValue. When the view refreshes its el will gain focus
if (!record.isEqual(value, startValue)) {
//debugger;
//Don't allow the model to write to the server, we want to update only the
//the cell that was changed.
//record.set(activeColumn.dataIndex, value);

Ext.Ajax.request({
url: '/todo/cellupdate',
params: {
uid: record.internalId,
cell: activeColumn.dataIndex,
value: value
},
success : function(response) {
// Restore focus back to the view's element.
if (sm.setCurrentPosition) {
sm.setCurrentPosition(sm.getCurrentPosition());
}
grid.getView().getEl(activeColumn).focus();

me.context.value = value;
me.fireEvent('edit', me, me.context);
},
failure : function(response){
alert(">>> override onEditComplete: Post Failed!");
}
});
}
}
}
});

22 Feb 2013, 11:50 AM
Anybody understand what I'm trying to accomplished here?