-
26 Nov 2010 2:31 AM #1
Store Applications Settings
Store Applications Settings
Hi Experts!
I want to store this kind of settings on the phone:
Objecttyp1 = on/off
Objecttyp2 = on/off
.
.
In a view I want to change the settings like here:Code:var settingsModel = Ext.regModel('mysettings', { fields: [ {name: "name", type: 'string'}, {name: "state", type: 'boolean'} ] });
How can I do that smooth? Thanks for help!Code:var settingsFormBase = { scroll: 'vertical', url : '<c:url value='/logout.jsp'/>', standardSubmit : true, floating: true, centered: true, modal : true, frame: true, width: Ext.is.Phone ? 320 : 400, height: Ext.is.Phone ? 320 : 400, items: [ { xtype: 'button', ui : 'decline', text: 'LOGOUT', handler: function() { settingsForm.submit(); } }, { xtype: 'fieldset', title: 'Layerauswahl', instructions: 'Aktivierte Layer werden in der Karte dargestellt.', defaults: { required: false, labelAlign: 'left' }, items: [ { xtype: 'togglefield', name : 'Objecttyp1', label: 'Objecttyp1' }, { xtype: 'togglefield', name : 'Objecttyp2', label: 'Objecttyp2' }, ] } ], dockedItems: [ { xtype: 'toolbar', dock: 'bottom', items: [ {xtype: 'spacer'}, { text: 'Ok', ui: 'confirm', handler: function() { settingsForm.hide(); } } ] } ] };
-
26 Nov 2010 7:54 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 29
you can use cookies or local storage.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
26 Nov 2010 6:24 PM #3Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Best way is probably something like this:
Code:Ext.regModel('Setting', { fields: ['name', 'state'], proxy: { type: 'localstorage', id : 'app-settings' } }); //store with autoLoad - pulls existing Setting instances out of localStorage var store = new Ext.data.Store({ model: 'Setting', autoLoad: { callback: function(records) { //'records' is now all of the loaded Setting model instances console.log(records); } } }); //add new settings store.add({name: 'someSetting', state: true}); //saves to localStorage store.sync();Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
29 Nov 2010 2:49 AM #4
@edspancer Thanks for your help and code! This is a good starting point for me. I tried your example, but all my setting records where added to the store like a INCERT statement. Is it possible to update a existing "setting" record in store? The console.log(records); are increase constantly.
How would you update the togglefields in the "settingsFormBase"? (code above)
-
30 Nov 2010 2:30 AM #5
My code until now, but I get all records, not only the latest updated records.
I would say there must be something missing like store.update({name: 'someSetting', state: false})).PHP Code:var records = store.getUpdatedRecords();
console.log('logme:'+records);
for (i=0; i < records.length;i++){
settingsForm.add({xtype: 'togglefield', name : records[i].data.name, label: records[i].data.name, value : records[i].data.state});
};
settingsForm.doLayout(); // refresh the layout
-
7 Feb 2011 12:23 PM #6
I've run across a bug: when making the Model proxy id 'app-settings', the code will error, however changing the id to 'appsettings' fixes it. A bug report has been submitted, but I'm not sure if it has more to do with Sencha or a webkit local storage naming restriction.
-
7 Feb 2011 1:55 PM #7Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Similar Threads
-
Project settings
By mic.b in forum Sencha Animator Feature RequestsReplies: 1Last Post: 22 Nov 2010, 1:46 AM -
Need Help on reset the settings for singleton GridPanel ColumnModel / Store
By just_a_kid in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 13 Sep 2010, 7:50 AM -
[DEFER-927] Store's api settings.
By Animal in forum Ext 3.x: BugsReplies: 0Last Post: 3 May 2010, 3:04 AM -
Calling ext GWT applications from legacy applications
By mathaj77 in forum Ext GWT: DiscussionReplies: 3Last Post: 14 Aug 2009, 4:15 AM -
application settings
By mnask79 in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 28 Nov 2008, 3:30 PM


Reply With Quote