PDA

View Full Version : Ext.getCmp for JsonStore is "undefined"



aaronbartell
18 Jan 2011, 1:56 PM
Hi All,

I need to gain access to a store and load it in a dynamic fashion. Normally something like


Ext.getCmp('storeid').load()


would work just fine, but it is not and instead comes up as undefined. Here is a full working example that shows what I mean:


<html>
<head>
<script type='text/javascript'
src='http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/release/adapter/ext/ext-base.js'></script>
<script type='text/javascript'
src='http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/include/ext-all.js'></script>

<script type="text/javascript">

Ext.onReady(function(){

var actIdStore =
new Ext.data.JsonStore({
id:'actIdStore',
autoLoad: false,
url: '/pgm/googmap',
baseParams: {action:'getActIdList'},
root: 'list',
fields: ['vfld','dfld']
});

// This does NOT work and instead comes up as undefined.
Ext.getCmp('actIdStore').load();

// This DOES load the JsonStore, though you need to comment out the above to get to this point.
actIdStore.load();

});
</script>
</head>
<body>
</body>
</html>


You can run it from this URL: http://www.sureyoucanhavethekeys.com/loadjsonstore.html

I have tried both id:'actIdStore' and storeId:'actIdStore' but neither work.

Any ideas?

AaronBartell.com
www.SoftwareSavesLives.com

18 Jan 2011, 5:16 PM
Ext.getCmp is a soft link to Ext.ComponentMgr.get. You want to use Ext.StoreMgr.get

aaronbartell
19 Jan 2011, 2:22 PM
That fixed it! Thanks jgarcia.

AaronBartell.com
www.SoftwareSavesLives.com