-
6 Aug 2010 6:40 AM #1Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
[FIXED-1185] Adding phantom/dirty records to a store doesn't make them modified
[FIXED-1185] Adding phantom/dirty records to a store doesn't make them modified
From this post:
Adding a phantom or dirty record to a store doesn't automatically add it to the internal modified array, which also means they won't get saved when calling save().
I suggest changing:
Code:Ext.override(Ext.data.Store, { add : function(records){ records = [].concat(records); if(records.length < 1){ return; } var modified = []; for(var i = 0, len = records.length; i < len; i++){ records[i].join(this); if (records[i].dirty || records[i].phantom) { modified.push(records[i]); } } var index = this.data.length; this.data.addAll(records); if(this.snapshot){ this.snapshot.addAll(records); } this.modified.push.apply(this.modified, modified); this.fireEvent('add', this, records, index); }, insert : function(index, records){ records = [].concat(records); var modified = []; for(var i = 0, len = records.length; i < len; i++){ this.data.insert(index, records[i]); records[i].join(this); if (records[i].dirty || records[i].phantom) { modified.push(records[i]); } } if(this.snapshot){ this.snapshot.addAll(records); } this.modified.push.apply(this.modified, modified); this.fireEvent('add', this, records, index); } });
-
6 Aug 2010 10:42 AM #2Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Nice, though I went for this (and a similar change for insert):
The main difference is that I'm just pushing to this.modified inside the loop - was there a reason you chose not to?Code:add : function(records) { var i, record, index; records = [].concat(records); if (records.length < 1) { return; } for (i = 0, len = records.length; i < len; i++) { record = records[i]; record.join(this); if (record.dirty || record.phantom) { this.modified.push(record); } } index = this.data.length; this.data.addAll(records); if (this.snapshot) { this.snapshot.addAll(records); } this.fireEvent('add', this, records, index); },Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
6 Aug 2010 10:43 AM #3Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
The change is now in svn and will appear in 3.3 beta 2
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
How to Add & Retrieve Phantom Records from a JSON Store?
By thedott in forum Ext 3.x: Help & DiscussionReplies: 3Last Post: 6 Aug 2010, 6:40 AM -
Store.rejectChanges() + phantom records
By Jonny5 in forum Ext 3.x: Help & DiscussionReplies: 3Last Post: 21 Jun 2010, 9:49 AM -
[CLOSED] TreeStore doesn't keep track of modified records
By ionut.rachita in forum Ext GWT: Bugs (2.x)Replies: 1Last Post: 1 Sep 2009, 12:12 PM -
Why deleted records don't go into Store.Modified[]?
By velislav in forum Ext 2.x: Help & DiscussionReplies: 8Last Post: 17 May 2009, 4:12 AM -
Ext.data.Store.remove() does not remove records from modified records array
By phillipL in forum Ext 1.x: BugsReplies: 1Last Post: 29 Jun 2007, 12:40 AM


Reply With Quote