最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ExtJs add, delete, update row to the grid - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question asked Nov 10, 2009 at 20:04 NatkeeranNatkeeran 1,7496 gold badges31 silver badges52 bronze badges 1
  • 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 Commented Jan 20, 2011 at 21:02
Add a ment  | 

3 Answers 3

Reset to default 3

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 ing 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 mitChanges() method of the "Store" object.

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.

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 (pared 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.

发布评论

评论列表(0)

  1. 暂无评论