2
votes

I need to enable the user to add a new row to the grid. The user may also update one or more rows.

What is the best way to do this?

I have tried to use RESTful Store Example, but have not been able to handle the REST posting with php.

When the add record button is clicked, it fires the POST twice (once upon clicking, and once when pressing the update).

Also, the updates are kept marked, even after posting to the db.

Thank you.

3
what was the end result to this question? I am facing the same issue and it even wont fire the update method after the first save.IEnumerator

3 Answers

3
votes

You should pay close attention to the code in the demo of the Row Editor. Notice that they added event listeners to the "add", "update", and "remove" events that (in this case) called a function of the store.

Not sure where your POST is coming from (since you haven't posted any code). Basically you would set a listener on the "update" event of your store. All of your edits happen locally, only affecting your local "Store" object, until you say otherwise. By attaching an event listener to the "update" event of the store, you can then have it handle POSTing the data back to the server, if the record actually changed if(record.dirty). The "Store" receives the "update" event, and the RowEditor receives an "afteredit" event. As far as change markers, look carefully at the commitChanges() method of the "Store" object.

1
votes

I recently had this same problem too (records still marked dirty even though response was clean). And I might have a solution for you. I was defining metaData for the JsonReader in-band and did not set a successProperty, making a horrible assumption that it would stick to the default of "success". Once I provided this all of the magic started working. My suggestion to you is to go over your configuration of the JsonReader and double check what kind of data you are sending it. The Reader is rather picky about what it gets back. You need to have idProperty, root, successProperty, etc all defined.

FWIW, it does throw an exception, but I never see it in Firebug's console. I had to go through the arduous task of stepping through Ext's code to find this problem.

1
votes

The double POST and records kept dirty are the same problem.

When something is modified in the grid, the list of modified records is sent to the server. You have to modify them and return them, these returned values are (compared with the current values in the store? and) updated in the store and marked as not dirty. So I think the problem is in the values you are returning from the server.

You have to be careful with the following: format problems (response structure, root property, ...), records listed in different order, records without an id (or id property not properly set) and success not set to true.