PDA

View Full Version : How to change another view in the MVC



Fent2
11 Feb 2014, 4:50 PM
I have twe view ,view1 and view2 ,
the view1 have a button ,press this button ,i want the view change to view2 ,
I try like this ,but unsuccess!

view define
Ext.define('Desktop.view.view1', {
extend: 'Ext.form.Panel',
alias : 'widget.view1',

buttons: [{
text: 'Reset',
action:'show_data',}]

......
})

view define
Ext.define('Desktop.view.view2', {
extend: 'Ext.grid.Panel',
alias : 'widget.view2',
......

in the controller

Ext.define('Desktop.controller.ProductDataCtrl', {
extend: 'Ext.app.Controller',
views: ['Desktop.view.view1'],
stores: [ 'Desktop.store.view1Store'],
models: ['Desktop.model.view1Model'] ,

init: function() {
this.control({

'view1 button[action=show_data]': {
click: this.show_data
},
});
},

show_data: function(button) {
var aa = Ext.create('Desktop.view.view2',{renderTo:Ext.getBody()});
aa.show();
}
.....

Zinnia
12 Feb 2014, 1:37 AM
You can try

1. Add 2 views as an items in a container. Initially hide the 2nd view in container . On click of button, show the 2nd view hide the first view.

Or

2. On click of button remove the first view from the container and add the 2nd view into the container