views:

7305

answers:

3

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.

+1  A: 

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.

Steve -Cutter- Blades
A: 

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.

A: 

how to post the request in row editor i don't have any idea?editor.on event to insert new row, but i dont how to process it further.. please help i am using php in backend?

mayuri
I am not understanding your question. For instance, adding a row involves inserting an item to the store ( Grid.store.insert(0, ProductTypeStruct);). To write back to the db, you can loop through all the dirty rows, and ajax it to php for insert or update.
Natkeeran