-
28 Dec 2011 11:21 AM #1
How to pass data to store
How to pass data to store
I have a list view that calls a store for the list data. I am trying to pass data to the store for filtering or a different url for the proxy how would I accomplish this?
List View:
Store:Code:Ext.define('MonkTouch.view.List', { extend : 'Ext.List', xtype : 'mtouch-list', storeId:null, constructor : function(config) { this.setItemTpl(config.template); Ext.apply(config, { store : Ext.create('MonkTouch.store.Media') }); this.callParent([config]); } });
Code:Ext.define('MonkTouch.store.Media',{ extend: 'Ext.data.Store', model: 'MonkTouch.model.Media', autoLoad: true, proxy:{ type:'ajax', url:'/lib/mk-modules/media.php', reader:{ type:'json', root:'items' } }, remoteFilter:true, filters:[] });
-
28 Dec 2011 11:43 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
If you want to change the url, I would add a little logic to the store definition you made.
Now you should be able to create a store like:Code:Ext.define('MonkTouch.store.Media', { extend: 'Ext.data.Store', model: 'MonkTouch.model.Media', autoLoad: true, remoteFilter:true, filters:[], constructor: function(config) { config.proxy = { type : 'ajax', url : config.url, reader : { type : 'json', root : 'items' } }; delete config.url; this.callParent(config); } });
Code:Ext.create('MonkTouch.store.Media', { url : '/lib/mk-modules/media.php' });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Dec 2011 12:57 PM #3
why did you do config.proxy instead of this.proxy?
-
28 Dec 2011 1:16 PM #4
Everytime I try to set config.proxy as you have above I get a JS error. The error just says "Error:".


Reply With Quote