PDA

View Full Version : Ext.data.AbstractStore forces model to always come from config



jep
29 Jun 2011, 9:13 AM
version 1.1.0 and the 4/18 SVN files

I wanted to extend a Store to always use a specific model (basically, trying to clean up my code and compartmentalize the spaghetti that had formed). So I had something of the form:



CustomerStore = Ext.extend(Ext.data.JsonStore, {
model: 'Contact'
});


I found that this failed and that the model for any CustomerStore object was null. I tracked this down to sencha-touch-debug.js on line 10143, the final line of this block from Ext.data.AbstractStore.constructor:



Ext.apply(this, config);

/**
* Temporary cache in which removed model instances are kept until successfully synchronised with a Proxy,
* at which point this is cleared.
* @private
* @property removed
* @type Array
*/
this.removed = [];

/**
* Stores the current sort direction ('ASC' or 'DESC') for each field. Used internally to manage the toggling
* of sort direction per field. Read only
* @property sortToggle
* @type Object
*/
this.sortToggle = {};

Ext.data.AbstractStore.superclass.constructor.apply(this, arguments);

this.model = Ext.ModelMgr.getModel(config.model);


As you can see, "Ext.apply(this, config)" was already called. there should be no need to rely on config anymore after that, and the properties from "this" should be used instead:



this.model = Ext.ModelMgr.getModel(this.model);


Unfortunately, there's a ton of other code in that constructor after this part that also uses "config" instead of "this". That should also be changed.