PDA

View Full Version : Updating ArrayStore after Grid update and sending the changes via Ajax



noncom
4 Mar 2013, 4:30 AM
I have a Grid that is linked to an ArrayStore, both are in the page script. The ArrayStore is filled with data during page generation. The Grid is enabled to edit fields, one at a time. After the edit, the Grid persists the changes and the whole ArrayStore is sent to server via AJAX (I have configured a proxy in it). All works. However, there are two problems that I am facing with it:

1) Although the Grid displays the newly entered value, the ArrayStore data does not change. As a consequence, what is sent to server with AJAX is the same data as the page was generated with, without any changes. How do I commit the changes from the Grid to the ArrayStore???

2) Upon synching, the whole table is sent. I want to avoid it by only sending the rows that have changed. How can I do that?

I have found some scarce examples of these topics but I cannot figure out a clear view of the matter...

noncom
4 Mar 2013, 11:23 PM
Does not anyone know anything about this here?

vadimv
5 Mar 2013, 11:03 AM
The ArrayStore has by default a memory proxy, not sure how you configured to sync with the server....and is not clear from your words how data is filled in store at page generation. If you would post some code...

So from your words I suppose you have sth like in the sencha example: http://docs.sencha.com/ext-js/4-1/#!/example/grid/row-editing.html . Then to get only updated records use store.getUpdatedRecords(). After that you need to commit so to not get them again second time, use store.commitChanges() for this. The same does the store.sync() method except that covers all operations: new, update, remove.


Hints: read in the docs about phantom and dirty records, see Ext.data.Model.


(http://docs.sencha.com/ext-js/4-1/#!/example/grid/row-editing.html)

noncom
13 Mar 2013, 4:31 AM
Well, finally I have dismissed using ArrayStore and simply created a Store with a proxy which handles the incoming and outcoming data with AJAX. I think that this is a better approach than I was using originally, where data was infused into the script during page generation. And the real problem was the bad design. Thanks for directions for additional info! I have followed that course and it improved my understanding rather quickly)