Create an extension with an xtype in ExtJS 4

klj picture klj · May 10, 2011 · Viewed 15.8k times · Source

I am used to ExtJS 3.X, but am struggling with ExtJS 4.

I want to create an extension of a grid and be able to use an instance of the grid with the xtype. As far as im aware, I have to set the alias as widget.xtypename but its not working for me.

var MyGrid = Ext.define('mygrid', {
    extend:'Ext.grid.Panel',
    alias: 'widget.mygrid',
    // rest of grid...
});

Ext.create('Ext.window.Window', {
    title:'My Window',
    items:[{
        xtype:'mygrid'
    }]
})

The Error I am getting in Chrome console is Cannot create an instance of unrecognized alias: widget.mygrid

Some help would be much appretiated

Answer

Kunal picture Kunal · Jun 21, 2011
 Ext.define('MyApp.Grid',{
            extend: 'Ext.grid.GridPanel',
            alias: 'widget.mygrid',
            .......
            .......
            }

Now you can use as xtype:'mygrid'