Doug Molineux
Doug Molineux

Reputation: 12431

Getting Component in ExtJS

I create a GridPanel like this:

grid = new xg.GridPanel({
    id: 'gridid',
    store: store,
    columns: [
    ...

Later on, I try to get the element so that I can load new data into it. In the Sencha Documentation it states that loadData is available to the GridPanel object

alt text

So I tried this:

Ext.getCmp('gridid').loadData(store);

And it chromes console prints this error:

Uncaught TypeError: Object [object Object] has no method 'loadData'

Interestingly, when I try

Ext.getCmp('gridid').getStore().loadData(store);

This error goes away and the current store disappears from the grid, but it remains empty, the new store isn't loaded. Please help!

UPDATE: When I console.log the store I see all the information inside the object as it should appear, but its not being rendered in the grid.

Upvotes: 1

Views: 4447

Answers (2)

wombleton
wombleton

Reputation: 8376

Assuming that the store that you're passing into the loadData function is not the same as the grid's store, try something like this:

var gridStore = Ext.getCmp('gridid').getStore();
gridStore.removeAll();
gridStore.add(store.getRange());

Upvotes: 3

Ben
Ben

Reputation: 21249

my Ext is a bit rusty but I'm pretty sure loadData is passed the data itself (e.g. an array of records/objects), not the store.

How did you declare your store? is it loading remote data or static local data?

There is an example of using loadData here: http://extjs.wima.co.uk/example/4

If you're using remote data, maybe you're just missing autoload on your store declaration..

Upvotes: 1

Related Questions