-
18 Dec 2012 8:15 AM #1
Answered: How to access a store from a groupFn and from an XTemplate?
Answered: How to access a store from a groupFn and from an XTemplate?
Hi,
I have defined a store with a groupTpl and a grouper. I want to access the store inside of both. How to do this? I know it has to do with the scope. But how? Thanks!
Code:Ext.define('MyApp.store.Demo', { extend : 'Ext.data.Store', config : { model : 'MyApp.model.Demo', autoLoad : false, groupTpl : new Ext.XTemplate('<div>{section:this.getGroupScore}</div>', { getGroupScore : function(section) { var store = this; //<-- "this" is not the store. How to get it? //... return 'test'; } }), grouper : { groupFn : function(record) { var store = this; //<-- "this" is not the store. How to get it? //... return record.data; } } } });
-
Best Answer Posted by Kurt001
Ext.getStore('storeName')
-
20 Dec 2012 6:42 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,120
- Vote Rating
- 453
- Answers
- 3160
If you really needed to get the store (not sure why) you could get the store off the record.
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.
-
24 Jan 2013 2:48 AM #3
How is this possible in getGroupScore() ? Please see my code. In groupFn() there is a parameter called record. But in getGroupScore() we don't have it.you could get the store off the record.
Thanks!
-
24 Jan 2013 5:32 AM #4
Ext.getStore('storeName')
-
24 Jan 2013 5:42 AM #5
-
24 Jan 2013 6:33 AM #6
I took the time for 1000 items and there is no time difference.
Should be safe to use.


Reply With Quote