-
29 Aug 2012 12:55 AM #1
Unanswered: Are Stores sharing the same Model objects?
Unanswered: Are Stores sharing the same Model objects?
In my app I have the need to display grids of redeemed/non-redeemed vouchers. I setup one Model ("VoucherModel") and configures two JsonP Stores - one for redeemed and one for non-redeemed and ties them up to the VoucherModel. The VoucherModel contains the JsonP Proxy to point to the server. The grids are displayed on separate tabs so I'd like to load them when needed.
When the user logs in I setup the stores with the URLs:
The actual result is however that both stores loads the redeemed voucher, leading me to suspect that the Stores shares the Model object.Code:Ext.getStore('ActiveVoucherStore').getProxy().url = UP8.config.backend + 'voucher/active'; Ext.getStore('RedeemedVoucherStore').getProxy().url = UP8.config.backend + 'voucher/redeemed';
I have worked around this by defining the JsonP Proxy directly on each Store and it now works - but will the shared Model bite me later?
Thanks,
/Mattias
-
29 Aug 2012 6:09 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
How are you defining your models? Are you placing the details (proxy,etc) in a constructor so they both can create their own instance?
Scott.
-
29 Aug 2012 9:35 PM #3
I'm using Sencha Architect to create the Model and bind to the Stores. Maybe this is the problem - as I have defined the proxy on the Model I simply deleted it from the Store... I'll try to add the Ext.data.proxy.JsonP to each of the Stores and delete it from the Model.
The Store's code is generated as:Code:Ext.define('MyApp.model.VoucherModel', { extend: 'Ext.data.Model', alias: 'model.vouchermodel', proxy: { type: 'jsonp', reader: { type: 'json' } } });
Code:Ext.define('MyApp.store.RedeemedVoucherStore', { extend: 'Ext.data.Store', alias: 'store.redeemedvoucherstore', requires: [ 'MyApp.model.VoucherModel' ], constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ storeId: 'MyJsonPStore1', model: 'MyApp.model.VoucherModel', proxy: { type: 'jsonp', reader: { type: 'json' } } }, cfg)]); } });


Reply With Quote