user2660930
user2660930

Reputation: 157

Javascript/ExtJS: Ext.getCmp('') leads to TypeError ... is not a function

I had some code and it used to work fine, now it doesn't anymore. I have a set of results, displayed in a GridPanel and I have a textfield to filter the results. When there is more than 3 letters entered, it will filter the display results accordingly. There is a listener in the textfield that will react to values being entered. Once something has been entered, it fires the following commands:

grid  = Ext.getCmp('shopGrid');
console.log(grid);
store = grid.getStore();
console.log(store);

if (strLen >= 3) {
    store.filter('NAME', input, true, false);

} else {
    store.clearFilter();
    store.load();
}

I have added console.log() to see what's going on. I get the grid put out into the console and it's an object with all kinds of elements, just a I would expect. It doesn't go any furhter though and terminates with the error message: "TypeError: Ext.getCmp(...).getStore is not a function"

I have encountered this kind of error message before, but I don't fully understand what it's trying to tell me yet, as my understanding of the inner workings of Javascript is rather limited. Within ExtJS the function getStore() is only defined for GridPanels. Could my problem be that getCmp() serves me with a standard object rather then a GridPanel? But then there is only one type of object within Javascript, right? Anyways, I'm using Ext Version 3.4.1. Any help or tips would be greatly appreciated.

Upvotes: 0

Views: 2821

Answers (1)

kevhender
kevhender

Reputation: 4405

You have set grid to be Ext.getCmp('shopGrid').getView(), so it is actually a reference to the view, not to the grid itself. Take off the getView() and it should work.

var grid  = Ext.getCmp('shopGrid'),
    store = grid.getStore();

Upvotes: 4

Related Questions