PDA

View Full Version : need some information about store proxy api



extremed
3 Nov 2011, 6:17 AM
Hi

This is my store code and my problem is once the update is done server returns

{"success":true}

but the grid still showing little red flag in cell. any idea why its not removing after a successful update?



Ext.create('Ext.data.Store', {
autoLoad : true,
autoSync : true,
fields : [
{name: 'ID', type: 'string'},
{name: 'item_code', type: 'string'}
],
storeId : 'stock_store',
pageSize : 20,
proxy : {
type : 'ajax',
actionMethods : 'POST',
api: {
read : BASE_URL+'raw_material_controller/load',
create : BASE_URL+'raw_material_controller/create',
update : BASE_URL+'raw_material_controller/update',
destroy : BASE_URL+'raw_material_controller/delete'
},
reader: {
type : 'json',
root : 'data',
totalProperty : 'total',
idProperty : 'ID',
successProperty : 'success',
messageProperty : 'message'
},
writer : {
type : 'json',
root : 'data'
},
listeners: {
exception: function(proxy, response, operation)
{
Ext.MessageBox.show({
title : 'REMOTE EXCEPTION',
msg : operation.getError(),
icon : Ext.MessageBox.ERROR,
buttons : Ext.Msg.OK
});
}
}
}
});

Regards

mitchellsimoens
3 Nov 2011, 8:47 AM
When you do an update or create, you need to return the data of the record.. say you create a record so the id field doesn't reflect a real id... The call sends the create call and the server generates a real id and returns all the data... the Store will now update the record with that real id.

extremed
3 Nov 2011, 9:44 AM
sorry for this, i didnt understand though.

so once update done i have to return the updated record with the success message?

flanders
3 Nov 2011, 12:42 PM
Yes you do. This allows for serverside altering to enforce some rules, incorporate derived data and things like that.



{
"success": true,
"data": { urRecord }
}