-
18 Jun 2010 8:02 AM #1
Stores and Models
Stores and Models
Trying to play with the kiva sample and convert it to use a regular store with a JsonReader backing it (reusing the back end from extjs development). I can't get it to work as I get an error that the model is undefined in ext-touch-debug line 11505.
Code:Ext.regModel('CheckModel', { fields: [ {name:'APAmount'}, {name:'Provider'}, {name:'ARAmount'}, {name:'ProfitAmt'}, {name:'ProfitPercent'}, {name:'State'}, {name:'City'}, {name:'Claimant'}, {name:'Payer'}, {name:'ApptDate'}, {name:'ApptType'}, {name:'Department'}, {name:'Speciality'} ] }); this.store = new Ext.data.Store({ id: 'edc-store-checks', storeId: 'edc-check-store', url: '/MessageHub.aspx', model: 'CheckModel', reader: new Ext.data.JsonReader({ root: 'Items', totalProperty: 'Count', id: 'openitems', model: 'CheckModel' }) });
Tried stepping thru the code (learning experience on doing that in Safari) and don't ever see a key being added to the underlying mixedcollection of the ModelMgr. Am I missing something (.90 version of touch).
-
18 Jun 2010 8:53 AM #2
Got the same issue, I just modified the code, try this:
Not a nice solution, but it is working for me. The main issue is automatically registering writers and readers since they are created automatically and no root, model and so on are attached
Code:Ext.data.JsonReader.override({ buildExtractors : function() { if (typeof this.model == 'string') { this.model = Ext.ModelMgr.types[this.model]; } Ext.data.JsonReader.superclass.buildExtractors.apply(this, arguments); if (this.root) { this.getRoot = this.createAccessor(this.root); } else { this.getRoot = function(root) { return root; }; } } }); Ext.data.JsonStore = Ext.extend(Ext.data.Store, { /** * @cfg {Ext.data.DataReader} reader @hide */ constructor: function(config){ if(config && config.url){ config.proxy = new Ext.data.AjaxProxy(config); } Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, { reader: new Ext.data.JsonReader(config) })); } }); Ext.reg('jsonstore', Ext.data.JsonStore);
-
18 Jun 2010 9:08 AM #3
That seemed to do the trick, thank you! Don't seem to get the load listener to work either. Did you have issues with it?
-
18 Jun 2010 9:31 AM #4
Now read the docs, event is no longer there.
-
18 Jun 2010 10:45 AM #5Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
In Sencha Touch the data package was rearchitected such that Stores have Proxies, which in turn contain their Readers and Writers, like this:
Defining a Reader directly on a Store is not currently supported. Thanks for pointing this out though as our docs on this are currently out of date.Code:this.store = new Ext.data.Store({ id: 'edc-store-checks', storeId: 'edc-check-store', url: '/MessageHub.aspx', model: 'CheckModel', proxy: { type: 'ajax', reader: { type: 'json', root: 'Items', totalProperty: 'Count' } } });Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
19 Jun 2010 3:52 AM #6
Thanks Ed. Spending more time in the touch code I realise that all though I am tempted to apply all of Ext JS techniques I need to be wary that touch currently supports it. Appreciate the efforts, so far I am happy with where this is headed
-
19 Jun 2010 12:03 PM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
19 Jun 2010 1:31 PM #8Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
8 Jul 2010 11:13 AM #9
-
8 Jul 2010 2:42 PM #10Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Put the url on the Proxy instead of the Store. The Proxy abstracts away the CRUD mechanism that the Store relies on, so a Store can switch between a LocalStorageProxy and an AjaxProxy and rely on the same interface. The url is therefore meaningful to the Proxy, not the Store.
This was a design change from the current Ext JS 3.x architecture, we're preparing documentation to guide developers through the usage of the data package.Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Similar Threads
-
How do I write models?
By mwmcmullen in forum Ext GWT: DiscussionReplies: 0Last Post: 26 Apr 2010, 5:30 AM -
Stores, sub-stores & filters - help
By Bobbin in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 15 Nov 2009, 1:10 PM -
XTemplate an nested models
By screw in forum Ext GWT: Help & Discussion (1.x)Replies: 4Last Post: 13 Aug 2009, 3:53 AM -
XTemplate an nested models
By screw in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 1 Feb 2009, 10:18 AM -
How to use Models, Binders, and Readers
By fernando in forum Ext GWT: Help & Discussion (1.x)Replies: 1Last Post: 12 Jun 2008, 11:44 AM


Reply With Quote

