PDA

View Full Version : How to activate a Panel ?



myput
7 Nov 2011, 6:28 AM
Hey, i have a nestedlist in a panel, in my controller, i would like destroy this nestedlist panel when i change of panel in my bottom toolbar.

I'm able to destroy this view by deactivate. But when i come back on the panel; there is nothing ... I create the function activate, but i don't know how to put inside. When i display an alert, it's okey, i can see the alert is showed when the panel is open. But when i try: setactiveItem, there is some bug with all the application...

this is the code of the controller:



Ext.regController('Directory', {


index: function(options) {
if ( ! this.indexView) {
this.indexView = this.render({
xtype: 'DirectoryIndex',
listeners: {
deactivate: function(indexView) {
App.views.DirectoryNestedList.destroy();
},
activate: function(indexView) {
alert("home");
}
}
});
}
this.application.viewport.setActiveItem(this.indexView, options.animation);
},

});


And the code of the nestedlist panel:



App.views.DirectoryNestedList = new Ext.NestedList ({
title: App.config._DirectoryTitle,
fullscreen: true,
store: App.stores.DirectoryIndexStore,
singleSelect: true,
displayField: 'name',
useTitleAsBackText: false,
backText: '',
getItemTextTpl: function() {
var tplConstructor = loadURL(App.config.host + App.config.DirectoryTPL + 'DirectoryIndex.html');
return tplConstructor;
},
});


App.views.DirectoryIndex = Ext.extend(Ext.Panel, {
title: App.config._DirectoryTitle,
fullscreen: true,
layout: 'fit',
items: [App.views.DirectoryNestedList]
});
Ext.reg('DirectoryIndex', App.views.DirectoryIndex);


can you help me please?

myput
7 Nov 2011, 7:14 AM
I found a solution, super dirty but it's working:

Controller:

Ext.regController('Directory', {

index: function(options) {
if ( ! this.indexView) {
this.indexView = this.render({
xtype: 'DirectoryIndex',
listeners: {
deactivate: function(indexView) {
App.views.DirectoryNestedList.destroy();
},
beforeactivate: function(indexView) {
App.views.DirectoryNestedList = new Ext.NestedList ({
title: App.config._DirectoryTitle,
fullscreen: true,
store: App.stores.DirectoryIndexStore,
singleSelect: true,
displayField: 'name',
useTitleAsBackText: false,
backText: '',
getItemTextTpl: function() {
var tplConstructor = loadURL(App.config.host + App.config.DirectoryTPL + 'DirectoryIndex.html');
return tplConstructor;
},
});
},
}
});
}
this.application.viewport.setActiveItem(this.indexView, options.animation);
},

});

and the view:


App.views.DirectoryIndex = Ext.extend(Ext.Panel, {
layout: 'fit',
});
Ext.reg('DirectoryIndex', App.views.DirectoryIndex);


Have you another solution please because it's dirty to code in the controller .....

myput
8 Nov 2011, 12:22 AM
up