-
26 Mar 2012 12:01 AM #1
Unanswered: Localstorage overwrite existing Data
Unanswered: Localstorage overwrite existing Data
Hello,
i try to use the local storage to save app-preferences, but every time i do, i get a new data record.
How can i override an existing record?
I tried to implement a field for "id" in my model and than passed a value of "1" (appPrefs_store.add({id:1, value: "value"})), but this doesn't work.
Currently each data record in the local storage has a key named as the model (appPrefs_Model-1, appPrefs_Model-2...).
Is it possible to choose the key myself e. g. "appPrefs", and than load/save the data by that key?
Thank you
-
26 Mar 2012 1:21 AM #2
First, retrieve the record you'd like to update, then update the record with a new value:
Code:var record = appPrefs_store.getById(1); record.set('value', "value"); appPrefs_store.sync();
-
26 Mar 2012 1:39 AM #3
Hello,
thank you for your answer.
An is it possible to use my own key or is it always the name of the model,
and than key/value pairs as json-data as "value".
Thanks
-
26 Mar 2012 1:40 AM #4
Well depends on what you want to do. Obviously you could put all data into one record expanding your model with new fields. Then you can specify what the info is, because the key in local storage will always be specified by Sencha.
-
26 Mar 2012 1:46 AM #5
Okay, that was what i wanted to know.
Thanks a lot


Reply With Quote