-
6 Feb 2012 3:36 AM #1
Unanswered: Editable grid RequestFactory - save
Unanswered: Editable grid RequestFactory - save
I'm trying to figure out the (best) approach for saving changes made with GridEditing when the datastore is populated with EntityProxies using requestfactory.
My current strategy:
populate grid:
1) requests all entityproxys
2) for each entityproxy request an editable entityproxy and add this to the store
save grid:
1) put the changed entityproxys in a list using store.getModifiedRecords()
2) store.commitChanges()
3) use the list to save the changed entityproxies with requestfactory
This works, but I feel like I only should request editable entityproxies when actually trying to save the changes to them, but I have no idea how to do that. Any recommendations?
-
11 Feb 2012 9:06 AM #2
I have a related issue
http://www.sencha.com/forum/showthre...RequestFactory
What you could do is potentially use the store.addStoreRecordChangeHandler .. and insert an editable proxy at that index ... but its not working .. you might end up getting:
Caused by: java.lang.IllegalStateException: A request is already in progress
when you persist :-(
-
11 Feb 2012 11:51 AM #3
If you get the "A request is already in progress", that indicates you're callin edit with a requestcontext that allready has been fired. You should use a new requestcontext. Would this fix your problem?
-
11 Feb 2012 1:09 PM #4
Hmm .. a new request object is being used:
One commit is called on the grid/store, this is invoked.
This is from the store insertion:Code:store.addStoreUpdateHandler(new StoreUpdateEvent.StoreUpdateHandler<AddressProxy>() { @Override public void onUpdate(StoreUpdateEvent<AddressProxy> event) { List<AddressProxy> items = event.getItems(); for(AddressProxy proxy : items) { addressRF.addressRequest().persist().using(proxy).fire(new Receiver<Void>() { @Override public void onSuccess(Void response) { System.out.println("Received persist response from server"); } @Override public void onFailure(ServerFailure error) { System.out.println("Error from persist response from server - " + error.getMessage()); } }); } } });
Will try to keep looking ..Code:addressRF.addressRequest().findAll().fire(new Receiver<List<AddressProxy>>() { @Override public void onSuccess(List<AddressProxy> response) { store.clear(); for( AddressProxy proxy : response) { AddressProxy editable = addressRF.addressRequest().edit(proxy); store.add(editable); } gridPanel.forceLayout(); } @Override public void onFailure(ServerFailure error) { System.out.println("Error from findAll - " + error.getMessage()); } });


Reply With Quote