Hello,
Recently I tried ExtJs 4.0.2a and MVC application architecture and I must say that's an awesome improvement. Using MVC you have so much of flexibility. Now you can organize your whole application in proper structure that can be easily maintained and updated. It's really powerful feature available in ExtJs 4.0. You can get more details about this from this link. The MVC Architecture
They have explained a straight forward application with a grid with CRUD operations. What I will explain is dynamically loading views. Please read above article before further reading this post.
I was having requirement to dynamically load different views on all the the use actions. For example I have following four views for my content panel.
app/view/content/UsersGrid.js
app/view/content/ProjectsGrid.js
app/view/content/PremimumUsersGrid.js
app/view/content/PortfolioGrid.js
and let's say I have assigned following aliases to all of the above views.
UsersGrid => 'UsersGrid'
ProjectsGrid => 'ProjectsGrid'
PremimumUsersGrid => 'PremimumUsersGrid'
PortfolioGrid => 'PortfolioGrid'
I have a content panel in my view port and in which above views would be loaded dynamically. I can add reference of ContentPanel in my content controller to get the instance of it dynamically.
refs: [
{
ref : 'contentPanel',
selector: 'ContentPanel'
}
]
refs is the new way in MVC to get the reference of the the control. Above code will create a function getContentPanel() dynamically and I can use it to get reference of Content Panel. Here ref property specify name of function. Selector specify xtype of control. This xtype can be set using alias as follow.
alias : 'widget.ContentPanel'
Now consider I have a button. On click of button I want to load UsersGrid. Following will be code to load content panel and creating and adding view dynamically.
var contentPanel = this.getContentPanel();
contentPanel .removeAll(); //removing existing views.
var usersGrid = Ext.create('MyApp.view.Content.UsersGrid');
contentPanel.add(usersGrid);
contentPanel.doLayout();
Same way you can load other views as well.
Recently I tried ExtJs 4.0.2a and MVC application architecture and I must say that's an awesome improvement. Using MVC you have so much of flexibility. Now you can organize your whole application in proper structure that can be easily maintained and updated. It's really powerful feature available in ExtJs 4.0. You can get more details about this from this link. The MVC Architecture
They have explained a straight forward application with a grid with CRUD operations. What I will explain is dynamically loading views. Please read above article before further reading this post.
I was having requirement to dynamically load different views on all the the use actions. For example I have following four views for my content panel.
app/view/content/UsersGrid.js
app/view/content/ProjectsGrid.js
app/view/content/PremimumUsersGrid.js
app/view/content/PortfolioGrid.js
and let's say I have assigned following aliases to all of the above views.
UsersGrid => 'UsersGrid'
ProjectsGrid => 'ProjectsGrid'
PremimumUsersGrid => 'PremimumUsersGrid'
PortfolioGrid => 'PortfolioGrid'
I have a content panel in my view port and in which above views would be loaded dynamically. I can add reference of ContentPanel in my content controller to get the instance of it dynamically.
refs: [
{
ref : 'contentPanel',
selector: 'ContentPanel'
}
]
refs is the new way in MVC to get the reference of the the control. Above code will create a function getContentPanel() dynamically and I can use it to get reference of Content Panel. Here ref property specify name of function. Selector specify xtype of control. This xtype can be set using alias as follow.
alias : 'widget.ContentPanel'
Now consider I have a button. On click of button I want to load UsersGrid. Following will be code to load content panel and creating and adding view dynamically.
var contentPanel = this.getContentPanel();
contentPanel .removeAll(); //removing existing views.
var usersGrid = Ext.create('MyApp.view.Content.UsersGrid');
contentPanel.add(usersGrid);
contentPanel.doLayout();
Same way you can load other views as well.