-
23 Jan 2010 10:14 PM #1
[3.1] Direct Store with API, Update action takes no parameters
[3.1] Direct Store with API, Update action takes no parameters
Hi again.
I configured a Direct Store with API actions, in Ext 3.0 everything was working perfectly, when I upgraded to 3.1, the "update" action isn't sending the parameters:
Here is the Request payload with version 3.1:
And the response:HTML Code:{"action":"Productos","method":"modificar","data":[],"type":"rpc","tid":11}
In version 3.0.0 the Request payload is:HTML Code:{"type":"exception","tid":11,"message":"Not enough required params specified for method: modificar on class Productos"}
HTML Code:{"action":"Productos","method":"modificar","data":["3","{\"id\":\"3\",\"nombre\":\"Tangram 1, aktuell Lektion 5-8\",\"precio\":481,\"cantidad\":\"5\"}"],"type":"rpc","tid":10}
And the response is:
HTML Code:{"type":"rpc","tid":10,"action":"Productos","method":"modificar","result":{"id":"3","nombre":"Tangram 1, aktuell Lektion 5-8","precio":481,"cantidad":5}}
I am using the same application only testing with the newer version, this is how I configured the store and was working in version 3.0.0 and isn't in 3.1
HTML Code:var productos_writer = new Ext.data.JsonWriter({ writeAllFields: true // write all fields, not just those that changed }); Productos = new Ext.data.DirectStore({ api: { read: Migolo.Productos.listar, update: Migolo.Productos.modificar }, paramOrder: ['buscar','start'], baseParams: { buscar: "" }, autoLoad: true, root: "data", reader: new Ext.data.JsonReader({ totalProperty: 'totalCount', idProperty: 'id', root: 'data' }, [{ name: 'id', mapping: 'id' },{ name: 'nombre', mapping: 'nombre' },{ name: 'precio', mapping: 'precio' },{ name: 'cantidad', mapping: 'cantidad' }]), writer: productos_writer });
I must say that the "read" action is working in both versions sending the right params.
Best regards, and sorry for my English.
Miguel González
-
25 Jan 2010 6:44 AM #2
Hi Miguel, I am also experiencing the same issue.
The 'update' action is firing but with empty data (It was working in 3.0.3).
I do not know why however...
-
25 Jan 2010 7:23 AM #3
I tracked down the problem and it seems to occur in the save method of the Ext.data.Store class definition (around line 20125):
When testing within my own program:Code:len = queue.length; if(len){ batch = ++this.batchCounter; for(var i = 0; i < len; ++i){ trans = queue[i]; console.debug(trans); // #### ADDED THIS data[trans[0]] = trans[1]; } console.debug(data); // #### ADDED THIS if(this.fireEvent('beforesave', this, data) !== false){ for(var i = 0; i < len; ++i){ trans = queue[i]; this.doTransaction(trans[0], trans[1], batch); } return batch; } }
trans contains the following array:
However, it seems like data[trans[0]] = trans[1]; is not working since when I output data, I get the following:Code:["update", [Object { id="3855", more...}]]
Object { update=}
As if trans[1] was empty
-
25 Jan 2010 7:39 AM #4
-
25 Jan 2010 7:52 AM #5
Hi Condor, you're right, the data object now seems to contain the correct information.
The data is still not being sent though, I'll keep trying to find something (using console.dir now !! )
-
25 Jan 2010 10:24 AM #6
This works in 3.1.x:
Try setting encode to false.Code:var writer = new Ext.data.JsonWriter ({ encode: false, // Very important, defaults to true writeAllFields : true }); var reader = new Ext.data.JsonReader ({ root : 'records', idProperty : 'event_person_id', totalProperty : 'totalCount', successProperty : 'success', messageProperty : 'message', fields : recordFields }); var proxy = new Ext.data.DirectProxy ({ api : { read: Zayso.Direct.Event_EventPerson.read, create: Zayso.Direct.Event_EventPerson.create, update: Zayso.Direct.Event_EventPerson.update }, paramsAsHash: true }); var gridStore = new Ext.data.DirectStore ({ // These all come from Store storeId : 'referee-signup-grid-store', baseParams : { event_id : this.eventId, base2: 'somthing' }, autoLoad : false, autoSave : false, remoteSort : false, sortInfo : { field : 'position_id', direction : 'ASC'}, writer : writer, reader : reader, proxy : proxy });
And I always use paramsAsHash which ends up sending all the parameters in one array. The direct functions use a len of 1.
-
25 Jan 2010 12:47 PM #7
Hi again,
Cerad, compring your code, I changed the writer to do an encode: false, and yes, it sends the data, so i think there is a problem with the encode function because I tried setting it to true and the update function sent empty data.
-
25 Jan 2010 7:14 PM #8
Unless you have a burning desire to encode the data then just leave it false.
-
25 Jan 2010 7:35 PM #9
I can manage that, a thing I didn't saw before is that the request is sent in a different way:
I get this:
Instead of this:HTML Code:{"action":"Productos","method":"modificar","data":[{"buscar":"","data":{"id":"3","nombre":"Tangram 1, aktuell Lektion 5-8","precio":480,"cantidad":"5"}}],"type":"rpc","tid":10}
I only added the encode: falseHTML Code:{"action":"Productos","method":"modificar","data":["3","{\"id\":\"3\",\"nombre\":\"Tangram 1, aktuell Lektion 5-8\",\"precio\":480,\"cantidad\":\"5\"}"] ,"type":"rpc","tid":10}Last edited by migolo; 25 Jan 2010 at 8:33 PM. Reason: Formatting


Reply With Quote
