PDA

View Full Version : Handle function after cell edit



dranix
28 Oct 2011, 12:57 AM
Hi everybody
I just learn ext 3, especially grid. I have coded the grid that user can edit cell, then press "Enter", and make the request to server. The code work very well. However I want to display some server side validation in grid, and I don't know how and where to handle the return value from the server.
Here my code:

var Book = Ext.data.Record.create([
{ name: 'id' },
{
name: 'book',
type: 'string'
}, {
name: 'author',
type: 'string'
}
]);


var proxy = new Ext.data.HttpProxy({
api: {
read: '@Url.Content("~/Book/List")',
create: '@Url.Content("~/Book/Create")',
update: '@Url.Content("~/Book/InLineEdit")',
destroy: '@Url.Content("~/Book/Delete")'
}
});


var reader = new Ext.data.JsonReader({
totalProperty: 'total',
//successProperty: 'success',
idProperty: 'id',
root: 'book',
messageProperty: 'message'
},
Book);


var writer = new Ext.data.JsonWriter({
encode: false,
writeAllFields: true,
listful: true
});


// JSON Store
var store = new Ext.data.JsonStore(
{
url: '@Url.Content("~/Book/List")',
proxy: proxy,
reader: reader,
writer: writer,
root: 'books',
autoLoad: false,
totalProperty: 'total',
idProperty: 'id',
autoSave: true,
fields: ['id', 'book', 'author']
});

Any help is really appreciated
Thank in advance

UPDATE:
I finally found it:


var proxy = new Ext.data.HttpProxy({
api: {
read: '@Url.Content("~/Book/List")',
create: '@Url.Content("~/Book/Create")',
update: '@Url.Content("~/Book/InLineEdit")',
destroy: '@Url.Content("~/Book/Delete")'
},
listeners: {
beforewrite: function (proxy, type, action, options, response, arg) {
//Write some code here
},
exception: function (proxy, type, action, options, response, arg) {
//Write some code here
}
}
});