Created
January 29, 2011 02:46
-
-
Save christocracy/801454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Loads an array of {@Ext.data.Model model} instances into the store, fires the datachanged event. This should only usually | |
* be called internally when loading from the {@link Ext.data.Proxy Proxy}, when adding records manually use {@link #add} instead | |
* @param {Array} records The array of records to load | |
* @param {Boolean} add True to add these records to the existing records, false to remove the Store's existing records first | |
*/ | |
loadRecords: function(records, add) { | |
if (!add) { | |
this.data.clear(); | |
} | |
this.data.addAll(records); | |
//FIXME: this is not a good solution. Ed Spencer is totally responsible for this and should be forced to fix it immediately. | |
for (var i = 0, length = records.length; i < length; i++) { | |
records[i].needsAdd = false; | |
records[i].join(this); | |
} | |
/* | |
* this rather inelegant suspension and resumption of events is required because both the filter and sort functions | |
* fire an additional datachanged event, which is not wanted. Ideally we would do this a different way. The first | |
* datachanged event is fired by the call to this.add, above. | |
*/ | |
this.suspendEvents(); | |
if (this.filterOnLoad && !this.remoteFilter) { | |
this.filter(); | |
} | |
if (this.sortOnLoad && !this.remoteSort) { | |
this.sort(); | |
} | |
this.resumeEvents(); | |
this.fireEvent('datachanged', this, records); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment