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 - - - - -
/** + + + 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. Edit options.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 the result['successProperty'] property. - * The server-code might set the successProperty to false if a database validation - * failed, for example. + * Success of the action is determined in the result['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:

+ \ No newline at end of file