[CLOSED] LocalStorage / Not Local storage for Store
Hi
This is in reference to an old post that I still have not found an elegant solution for...however now I have a theory which may improve what I am currently doing...
Old Post - http://forums.ext.net/showthread.php...061#post208061
To sum the old post up - I have a page which can create a "quote" it contains a large number of details with grids and their associated stores - 9 in all. A user may create a new quote and nothing is persisted until you click the save button. The data structure is complex with a series of master / child relationships from store to store and becomes more complicated when you have phantom records referencing other phantom records. I have handcrafted a lot of this to be handled and saving is working but there are occasions where this fails.
In addition to this the field has a load of closable/auto hiding/carosuel etc and lots of javascript. If for whatever reason a javascript bug is hit it is nearly impossible to recover which means losing a lot of data (as the save has not yet occured).
Anyway, my theory now is that I can use localstorage until im ready to save using it as a somewhat backup service.
So my theory is:
For each store:
1. Load data from db to each store
2. Tell the store to use localstorage by changing its proxy to LocalStorageProxy and then make a save on the store to persist to client browser.
3. The user can then edit the screen and the app can persist silently to local storage either perodically with time based polling or systematically (after row updates etc).
4. When the user hits save tell the store to use non-localstorage proxy and commit records
This then means that if it fails I can implement some function to pull the data back from local storage when the user restarts the screen.
I have tried to get this working but I am having a problem changing the localstorageproxy of the store at runtime. I have got a workaround that does sort of work it is a lot more work and not a very nice solution which involves using a duplicate store.
For each store:
1. I setup two stores (1 for local storage and the other normal)
2. On page load I persist data from db into non local storage store (serverside)
3. On Ext.onReady (javascript) I copy data from non localstorage store to localstorage store then call the save button on the localstorage store to persist to client browser.
4. The user edits the quote and perodically the localstorage persists data to the client browser (silently)
5. When user hits save I need to copy data back out from localstoarge store to non localstorage store and then sync to server.
So this works but ideally I would like to only have one store but be able to change proxy from non localstorage to localstorage and back again. This will negate the need for two stores and all the extra work.
Hopefully this makes sense. Really I am just looking for a way to change a store's proxy to localstorage and back again.
Kind Regards
Glen