-
10 Apr 2012 12:44 PM #1
Model Field: persist:false does not work
Model Field: persist:false does not work
Hi guys,
If I set a field to persist:false it still gets persisted to the localstorage.
Thanks
Bob
-
10 Apr 2012 12:51 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,704
- Vote Rating
- 435
Thanks for the report. I have made a test case for you:
Code:new Ext.data.Store({ fields : [ { name : 'text' }, { name : 'foo', persist : false } ], data : [ { text : 'Test', foo : 'bar' } ], proxy : { type : 'localstorage', id : 'test' } }).sync();Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 May 2012 4:49 AM #3
Don't know if that bug has been fixed yet... in case it hasn't:
Don't know if that bug has been fixed yet... in case it hasn't:
this works for me in sencha touch 2.0.0:
Code:Ext.define('My.override.of.ext.data.proxy.WebStorage', { override: 'Ext.data.proxy.WebStorage', setRecord: function(record, id){ if (id) { record.setId(id); } else { id = record.getId(); } var me = this, rawData = record.getData(), data = {}, Model = me.getModel(), fields = Model.getFields().items, length = fields.length, i = 0, field, name, obj, key, dateFormat; for (; i < length; i++) { field = fields[i]; name = field.getName(); if(field.getPersist() === false){ continue; } if (typeof field.getEncode() == 'function') { data[name] = field.getEncode()(rawData[name], record); } else { if (field.getType().type == 'date' && Ext.isDate(rawData[name])) { dateFormat = field.getDateFormat(); if (dateFormat) { data[name] = Ext.Date.format(rawData[name], dateFormat); } else { data[name] = rawData[name].getTime(); } } else { data[name] = rawData[name]; } } } obj = me.getStorageObject(); key = me.getRecordKey(id); //keep the cache up to date me.cache[id] = record; //iPad bug requires that we remove the item before setting it obj.removeItem(key); obj.setItem(key, Ext.encode(data)); } });Martin Videc,
levatis GmbH (Austria) Software Developer
For more information about me visit www.videc.at
-
11 Jul 2012 2:03 AM #4
Currently the id is also saved to the value. ExtJS does not save the id.
What behavior is the correct one?
-
17 Jul 2012 8:09 AM #5Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
This has been fixed for the next release. Thanks for the report and the fix!
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-2724
in
Sprint 23 (2.0.3/2.1.0-b1).


Reply With Quote
