X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/docs/source/Store.html diff --git a/docs/source/Store.html b/docs/source/Store.html index 4937025a..d0698207 100644 --- a/docs/source/Store.html +++ b/docs/source/Store.html @@ -1,11 +1,17 @@ - -
-/** + + +The source code + + + + +/*! + * Ext JS Library 3.0.3 + * Copyright(c) 2006-2009 Ext JS, LLC + * licensing@extjs.com + * http://www.extjs.com/license + */ +/** * @class Ext.data.Store * @extends Ext.util.Observable *+ *The Store class encapsulates a client side cache of {@link Ext.data.Record Record} @@ -68,6 +74,9 @@ var recId = 100; // provide unique id for the record var r = new myStore.recordType(defaultData, ++recId); // create new record myStore.{@link #insert}(0, r); // insert a new record into the store (also see {@link #add}) *
Writing Data
+ *And new in Ext version 3, use the new {@link Ext.data.DataWriter DataWriter} to create an automated, Writable Store + * along with RESTful features. * @constructor * Creates a new Store. * @param {Object} config A config object containing the objects needed for the Store to access data, @@ -96,7 +105,7 @@ Ext.data.Store = function(config){ } Ext.apply(this, config); - + this.paramNames = Ext.applyIf(this.paramNames || {}, this.defaultParamNames); if(this.url && !this.proxy){ @@ -114,7 +123,8 @@ Ext.data.Store = function(config){ this.recordType = this.reader.recordType; } if(this.reader.onMetaChange){ - this.reader.onMetaChange = this.onMetaChange.createDelegate(this); + //this.reader.onMetaChange = this.onMetaChange.createDelegate(this); + this.reader.onMetaChange = this.reader.onMetaChange.createSequence(this.onMetaChange, this); } if (this.writer) { // writer passed this.writer.meta = this.reader.meta; @@ -246,6 +256,7 @@ var grid = new Ext.grid.EditorGridPanel({ * @event clear * Fires when the data cache has been cleared. * @param {Store} this + * @param {Record[]} The records that were cleared. */ 'clear',
/** @@ -287,7 +298,7 @@ var grid = new Ext.grid.EditorGridPanel({ 'loadexception', /** * @event beforewrite - * @param {DataProxy} this + * @param {Ext.data.Store} store * @param {String} action [Ext.data.Api.actions.create|update|destroy] * @param {Record/Array[Record]} rs * @param {Object} options The loading options that were specified. Editoptions.params
to add Http parameters to the request. (see {@link #save} for details) @@ -297,9 +308,8 @@ var grid = new Ext.grid.EditorGridPanel({ /** * @event write * Fires if the server returns 200 after an Ext.data.Api.actions CRUD action. - * Success or failure of the action is available in theresult['successProperty']
property. - * The server-code might set thesuccessProperty
to false if a database validation - * failed, for example. + * Success of the action is determined in theresult['successProperty']
property (NOTE for RESTful stores, + * a simple 20x response is sufficient for the actions "destroy" and "update". The "create" action should should return 200 along with a database pk). * @param {Ext.data.Store} store * @param {String} action [Ext.data.Api.actions.create|update|destroy] * @param {Object} result The 'data' picked-out out of the response for convenience. @@ -318,7 +328,8 @@ var grid = new Ext.grid.EditorGridPanel({ scope: this, add: this.createRecords, remove: this.destroyRecord, - update: this.updateRecord + update: this.updateRecord, + clear: this.onClear }); } @@ -496,7 +507,7 @@ sortInfo: { * internally be set to false. */ restful: false, - + /** * @cfg {Object} paramNames *An object containing properties which specify the names of the paging and @@ -516,7 +527,7 @@ sortInfo: { * the parameter names to use in its {@link #load requests}. */ paramNames : undefined, - +
/** * @cfg {Object} defaultParamNames * Provides the default values for the {@link #paramNames} property. To globally modify the parameters @@ -533,13 +544,17 @@ sortInfo: { * Destroys the store. */ destroy : function(){ - if(this.storeId){ - Ext.StoreMgr.unregister(this); + if(!this.isDestroyed){ + if(this.storeId){ + Ext.StoreMgr.unregister(this); + } + this.clearData(); + this.data = null; + Ext.destroy(this.proxy); + this.reader = this.writer = null; + this.purgeListeners(); + this.isDestroyed = true; } - this.data = null; - Ext.destroy(this.proxy); - this.reader = this.writer = null; - this.purgeListeners(); }, /** @@ -582,6 +597,7 @@ sortInfo: { remove : function(record){ var index = this.data.indexOf(record); if(index > -1){ + record.join(null); this.data.removeAt(index); if(this.pruneModifiedRecords){ this.modified.remove(record); @@ -605,14 +621,25 @@ sortInfo: { * Remove all Records from the Store and fires the {@link #clear} event. */ removeAll : function(){ - this.data.clear(); + var items = []; + this.each(function(rec){ + items.push(rec); + }); + this.clearData(); if(this.snapshot){ this.snapshot.clear(); } if(this.pruneModifiedRecords){ this.modified = []; } - this.fireEvent('clear', this); + this.fireEvent('clear', this, items); + }, + + // private + onClear: function(store, records){ + Ext.each(records, function(rec, index){ + this.destroyRecord(this, rec, index); + }, this); }, /** @@ -684,6 +711,14 @@ sortInfo: { this.lastOptions = o; }, + // private + clearData: function(){ + this.data.each(function(rec) { + rec.join(null); + }); + this.data.clear(); + }, + /** *Loads the Record cache from the configured {@link #proxy} using the configured {@link #reader}.
*Notes:
@@ -815,10 +850,12 @@ sortInfo: { var doRequest = true; if (action === 'read') { + Ext.applyIf(options.params, this.baseParams); doRequest = this.fireEvent('beforeload', this, options); } else { - // if Writer is configured as listful, force single-recoord rs to be [{}} instead of {} + // if Writer is configured as listful, force single-record rs to be [{}] instead of {} + // TODO Move listful rendering into DataWriter where the @cfg is defined. Should be easy now. if (this.writer.listful === true && this.restful !== true) { rs = (Ext.isArray(rs)) ? rs : [rs]; } @@ -835,10 +872,11 @@ sortInfo: { // Send request to proxy. var params = Ext.apply({}, options.params, this.baseParams); if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) { - params.xaction = action; + params.xaction = action; // <-- really old, probaby unecessary. } - // Note: Up until this point we've been dealing with 'action' as a key from Ext.data.Api.actions. We'll flip it now - // and send the value into DataProxy#request, since it's the value which maps to the DataProxy#api + // Note: Up until this point we've been dealing with 'action' as a key from Ext.data.Api.actions. + // We'll flip it now and send the value into DataProxy#request, since it's the value which maps to + // the user's configured DataProxy#api this.proxy.request(Ext.data.Api.actions[action], rs, params, this.reader, this.createCallback(action, rs), this, options); } return doRequest; @@ -921,7 +959,7 @@ sortInfo: { var actions = Ext.data.Api.actions; return (action == 'read') ? this.loadRecords : function(data, response, success) { // calls: onCreateRecords | onUpdateRecords | onDestroyRecords - this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, data); + this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, [].concat(data)); // If success === false here, exception will have been called in DataProxy if (success === true) { this.fireEvent('write', this, action, data, response, rs); @@ -992,7 +1030,7 @@ sortInfo: { // @protected onDestroyRecords proxy callback for destroy action onDestroyRecords : function(success, rs, data) { // splice each rec out of this.removed - rs = (rs instanceof Ext.data.Record) ? [rs] : rs; + rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs); for (var i=0,len=rs.length;i
- + + \ No newline at end of file