sermolaev
sermolaev

Reputation: 995

Ext.create returns constructor instead of object

Ext.application({
        name: 'test',
        launch: function() {
            var grid = Ext.create('Ext.grid.Panel', {
                id:'grid',
                renderTo: Ext.getBody(),
                store: userStore,
                width: 400,
                height: 200,
                title: 'Application Users',
                columns: [
                    {
                        text: 'word1',
                        width: 100,
                        sortable: false,
                        hideable: false,
                        dataIndex: 'word1'
                    },
                    {
                        text: 'word2',
                        width: 100,
                        sortable: false,
                        hideable: false,
                        dataIndex: 'word2'
                    }
                ],
                dockedItems: [
                    {
                        xtype: 'pagingtoolbar',
                        store: userStore,
                        dock: 'bottom',
                        displayInfo: true
                    }
                ]
            });

            //error here
            grid.reload();

I see error in console:

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

In debugger I see that variable 'grid' has type of 'constructor'

grid:constructor

So it's no wonder why there is no method 'reload'. It's wonder for me why I'm getting a reference to constructor function instead of reference to newly created object.

The same problem occurs when instantiating another ExtJs core classes.

May it somehow be related to my project structure?

P.S. I'm new to JavaScript, so it will be no surprise for me if the problem is in my poor understanding of core concepts.

Upvotes: 1

Views: 280

Answers (1)

Evan Trimboli
Evan Trimboli

Reputation: 30082

The problem is that the grid has no reload method, loading is handled by the store, so you want grid.getStore().load();

The first thing to do is check the docs, you'll see there's no reload method on a grid.

Upvotes: 1

Related Questions