PDA

View Full Version : RowEditor without autosave



frrogoy
6 Apr 2010, 4:33 AM
Anyone know how to get the roweditor to work without the autosave? I haven't been able to find a place where a listener will hear the afteredit event. Is that the right event to listen for?
I like the roweditor but it has several quirks that I could handle if I could control the saving.
1) It does a create as soon as you start to edit a new record. Once you enter the real data and press update, it does another create. So you get 2 records. I coded around this by looking for the default data and ignoring the create.
2) If you create a record, then edit the same record before refreshing the grid, it does another create.
3) If for any reason a create or update fails (sql error), a subsequent update attempt has a second record appended to the first. The JSON array is formatted correctly, but my update module was only expecting to have to update one record. Is this intentional behavior?

jimmifett
6 Apr 2010, 4:58 AM
You may wish to verify with fiddler or some similar tool. It does the initial create for me, then an update after i 'update' that row.

If using firebug, make sure you aren't getting 'realize' errors during the initial create. this would be from your server side portion not returning expected data roweditor needs to work properly.

finally, you could might be able to manually specify CRUD handlers in the store via the 'api' config item.

-J

Condor
6 Apr 2010, 5:36 AM
Are you sure you are returning the correct data for a 'create' (mainly the 'id')?

It looks like the record isn't de-phantom-ised after it is created, so it calls 'create' when it should be using 'update'.

frrogoy
7 Apr 2010, 4:35 AM
I didn't know I was supposed to return the ID! And I have read what I could find on the roweditor and writers. I must have missed that. So, my next dumb questions is: Where do I find what should be returned and when, and in what format?
I am using a common PHP module to handle the create, update and destroy.

And I still really don't want to do the create as soon as "New Record" is pressed. If the user subsequently presses cancel, I'd have an extra blank record in my db.

frrogoy
14 Apr 2010, 6:35 AM
More experimentation and I got it figured out. For the phantom create, I just ignore it and return {success: true}

On the real create (after the user enters data) I get the last insert id and return:
{success: true, data: {"ID": "90"}}

The ext gremlins then associate the value with the key in the store and a subsequent update is an update rather than another create...