In old version of ExtJs how do we get reference of any component? Either we use control.getComponent() method or we use Ext.getCmp('controlID') method. This will give you an instance of particular component. So how do we get instance of views in ExtJs 4 MVC?
it has something called refs. You can add reference to any views in any controller.
refs: [
{
ref : 'myGrid',
selector: 'myGrid'
}
]
Here selector is the type of the component. This use can set with alias for views. For Example.
Ext.define('myApp.myGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.myGrid',
initComponent: function () {
this.callParent(arguments);
}
});
ExtJs MVC has something called component query. This will be used to get reference of particular type of component.
ref creates a function with name specified there and you can use that function to get reference of that particular component.
You will get reference of myGrid by following code inside controller.
var myGrid = this.getMyGrid();
Remember here that it will not create new instance of grid. It will give a reference to an existing instance. If no instance is available it will return null. To know how to create an instance of view check out my earlier blog here.
it has something called refs. You can add reference to any views in any controller.
refs: [
{
ref : 'myGrid',
selector: 'myGrid'
}
]
Here selector is the type of the component. This use can set with alias for views. For Example.
Ext.define('myApp.myGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.myGrid',
initComponent: function () {
this.callParent(arguments);
}
});
ExtJs MVC has something called component query. This will be used to get reference of particular type of component.
ref creates a function with name specified there and you can use that function to get reference of that particular component.
You will get reference of myGrid by following code inside controller.
var myGrid = this.getMyGrid();
Remember here that it will not create new instance of grid. It will give a reference to an existing instance. If no instance is available it will return null. To know how to create an instance of view check out my earlier blog here.