PDA

View Full Version : simple grid autosave bug



zhupanenko
16 Mar 2010, 12:55 PM
i have quite simple grid and store assosiated with it



var cityStore = new Ext.data.JsonStore({
method: "POST",
url: 'cities.php?type=list',
root: 'cities',
idProperty: 'id',
totalProperty: 'count',
successProperty:'success',
remoteSort: true,
fields: ['id', 'title', 'titleu'],
writer: new Ext.data.JsonWriter(),
autoSave: true
});


when i try to edit grid fields it saves to DB only my first editing. actually i've found the reason why it treats so. arrays that i get from extJs while editing 3 fields one after another look like:



array (
'type' => 'list',
'cities' => '{"titleu":"1","id":"2564"}',
'xaction' => 'update',
)
array (
'type' => 'list',
'cities' => '[{"titleu":"1","id":"2564"},{"titleu":"2","id":"2628"}]',
'xaction' => 'update',
)
array (
'type' => 'list',
'cities' => '[{"titleu":"1","id":"2564"},{"titleu":"2","id":"2628"},{"titleu":"3","id":"2561"}]',
'xaction' => 'update',
)


that means it stores old info about editing in every json package.
how can i change it ? i want to get a single array with current edited field info

puow
19 May 2010, 10:00 AM
I have exactly the same issue have you had any luck?

puow
20 May 2010, 2:08 AM
Doh!

My problem was in the server side call (I was returning an empty json string). I am now successfully passing back a success value of true: if I change this to false i get the same behaviour. I am presuming that if the client does not receive a happy success flag from the server then the changed data is still marked as dirty and is resubmitted next time you make another change.

I have corrected this error and am now processing json arrays using listful set to true on the writer so as to pickup any failed updates.

I've also corrected my exception handling that wasn't reporting an error or at best was reporting a cryptic one.