View Full Version : Write event not firing.

12 Apr 2010, 11:28 AM

I'm having some trouble with finishing up an editable grid I have been creating. When the user finishes doing the editing, I send a batch request of all fields in an edited row to the server for processing.

All that works. The 'problem' I'm having is that I cannot seem to get the write event to do anything. What I would like is to have some feedback that the batch save worked, and perhaps redirect on success. If I can get the event to fire so I can execute some normal javascript, I could take it from there. But for whatever reason, it's not firing.

I've tried a dozen different formats I've found searching the forums. I'm thinking my JSON response is poorly formatted. I'm returning :
{"total": -1,"success": true,"exception": null,"dataresults": []}

Which is one of the setups I've seen in the various forum posts.

For the actual write event, as I said, I've tried a ton of different ways. Latest was:

store.on("write", function(store, action, result, res, rs) {

Which doesn't do anything. Using firebug I know I'm getting a response, and the response is that JSON, but I can't figure out why the event isn't firing.

Can someone please help me out? Let me know if you need more code, but it's just a standard store and json writer/reader. I don't think the rest should matter.

Thank you!

19 Apr 2010, 6:49 AM
Anyone have any idea here? I've tried a dozen more combinations, return json messages, etc. I'm down to just {"success": true } on the json, and basically any combination inbetween.

I've tried adding the call back function on the store directly, as a separate entity onWrite, and any other combination I can find...I've spent hours searching the forums and google and throwing in any implementation I can find with no success.


19 Apr 2010, 9:36 AM
So, I'm apparently throwing an exception somehow. My response is a 200, so it has to be my json format. What is the correct response Json for a 'create' request type? I don't need to get the IDs (they're multi-part anyway, which would be annoying) back; all I need to do is confirm success.

Can anyone help me out on that front? I've tried a ton of different examples, and the information given to the exception event isn't all that helpful.


19 Apr 2010, 10:41 AM
OK, I think this thread has the answer:

I need to return the IDs of the elements. This is a problem, though, since it is a 3 part ID (at best). The idproperty documentation for JsonReader only says for the singular ID. How do I get a multi-part to work, or get around returning the ID? I really don't care about the IDs for the new records.

When I just return the passed in rows, I get this:
uncaught exception: Ext.data.DataReader: #realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.

When I put in an ID of one of the columns in my grid, it worked - no exception, no error, etc. Buuut...it also filtered my grid to one row, since that one column isn't unique. And if I try to put a comma separated list in the idProperty, it displays everything, but doesn't know what to do about reading it later (it thinks the ID is called "blah1, blah2, blah2").

Any solutions around?


19 Apr 2010, 1:02 PM
add a property to your json response with looks like
not really nice but it works

20 Apr 2010, 11:00 AM
I ended up making the grid more limited than I had originally planned, which allowed for a single unique key - already displayed in the grid.

Once I did that, and passed back the post json, it worked. That is quite annoying, though, to have to return all the data sent (unless you want to really process out just the 'id'). All I wanted was a property for 'yup, it worked'.

Whatever. All is good now.

I really wish the documentation and examples truly explained this type of thing. They're pretty limited.