PDA

View Full Version : How to close a MVC Ext.app.Controller



Fent2
16 Dec 2013, 7:21 PM
I use left tree to ctreate a new controler and it's view(grib panel) ,and add to the Ext.tab.panel,
once user close the tab , the controller and it's view can destroy.
Now i have a problem,one the the tab close and open and close again ,the ViewClose() will execute more then one time,so others event handler;
So i think their some resource not release ,
Some one can help me ?

I user like this:



I user like this:
=====================================
the controller js
Ext.define('Desktop.controller.UserManagerCtrl', {
extend: 'Ext.app.Controller',
views: ['Desktop.view.UserManagerView','Desktop.view.UserManager.UserInfo' ],
stores: [ 'Desktop.store.UserManagerStore'],
models: ['Desktop.model.UserManagerModel'] ,

init: function() {

this.control({

'UserManagerView': {
close: this.ViewClose
},
)
},
ViewClose:function()
{
var sss = this.application.controllers;
console.log(' ViewClose:function()');
sss.remove(this );
}
......
});

========================================
the view js
Ext.define('Desktop.view.UserManagerView', {
extend: 'Ext.grid.Panel',
....
)}
the main controllers manager
============================
var new_view = null;
// node.data.component,the name of a controller form left tree node
var controller = this.application.controllers.get(node.data.component);
if(!controller)
{
var sss = this.application.getController(node.data.component);

sss.init();
var viesss = sss.views[0];
new_view = Ext.create(viesss);
sss.myviewshandle = new_view;
tab.add(new_view);
}else
{
new_view = controller. myviewshandle;

}
var aa = tab.getComponent(new_view);
tab.setActiveTab(new_view);

scottmartin
18 Dec 2013, 3:32 PM
It is highly recommended that you do not try to dump controllers. It is not good practice.

That being said, here is a example of how this may be approached: (not recommended/supported)
1d6

Fent2
18 Dec 2013, 7:17 PM
Thank you very much,
I want to delete the controller ,because their some module(user MVC architecture) in the web ,
and a module's view show in tab panel,once user close the tab , the controller can delete ,
because i worry the memory will grow up while user open and close a lot module high frequency.
or maybe you can give me some good usage ? thank you !


It is highly recommended that you do not try to dump controllers. It is not good practice.

That being said, here is a example of how this may be approached: (not recommended/supported)
1d6