PDA

View Full Version : Controllers and stores do not work



sdd0
5 Nov 2013, 11:34 PM
Hi,

I create a tabpanel after clicking a treepanel.



Ext.define('zldapp.controller.Treepanel.Treepanel', {
extend: 'Ext.app.Controller',

init: function() {
var myheader = this.header;
this.control({
'treepanel > zytreepanel': {
select: this.onPanelSelect
}
});
},

onPanelSelect: function(selModel, record) {
if (record.get('leaf')) { //it's a leaf
debugger;
CreatePage.init(record.getId());
}
}
});


I use an ajax request to get a tabpanel back and use "eval" to execute tabpanel to create.



Ext.define('zldapp.common.CreatePage', {
singleton: true,
alternateClassName: ['CreatePage'],
pageId: null,
showCmd:null,
tabs: null,
init: function(pageId){
me = this;
me.pageId = pageId;
Ext.Ajax.request({
url : './data/Zytab/'+pageId+".json",
method:'POST',
scope : this,
success : function(response, opts){
var response = Ext.decode(response.responseText);
me.showCmd = response.show;
me.tabs = response.tabs;


Ext.Ajax.request({
url: me.getURL(me.pageId, me.tabs),
success: function(response){
eval(response.responseText );
}
});
},
failure : function(response, opts){
}
});
}
});


My tabpanel looks like:



Ext.define('zldapp.view.VPN.Connection', {
alias: 'widget.zyconnection',
extend: 'zldapp.view.Zytab.Zytab',
controllers:['VPN.Connection'],
stores: ['VPN.showPRcontroll', 'VPN.showCryptMap', 'VPN.showAddress', 'VPN.showAddressGrp'],
itemId:'zyconnectionTab',
initComponent: function() {
Ext.apply(this, {
header:false,
activeTab: 0,//for tab
title: 'Connection',
border: false,
defaults:{layout:'fit'},
items: {
xtype: 'form',
labelWidth: 30, // label settings here cascade unless overridden
layout: 'form',
id : 'connection',
bodyPadding: '50 150 150 20',
defaults: {
anchor : '70%',
labelAlign: 'left'
},
items: [


*****************
],


buttons: [
*****************
]
}
});

this.callParent(arguments);
}
});


Ext.onReady(function(){
var tabs = Ext.create('widget.zyconnection');

var contentPanel = Ext.ComponentQuery.query('viewport > panel[region="center"]');
contentPanel[0].removeAll();
contentPanel[0].add(tabs);
contentPanel[0].doLayout();
});


The page has been opened and displayed successfully, but it cannot execute the controller :
controllers:['VPN.Connection']

It also doesn't create stores. I checked those situations by debugger tool, I noticed there are only 'view' files to be downloaded, there is no any 'store' and 'controller' file. Could anyone please help me to figure out what my problem is?

46718

sdd0
6 Nov 2013, 1:25 AM
I forgot to mention my zytab controller :



Ext.define('zldapp.controller.Zytab.Zytab', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'tabpanel [active = true]': {
tabchange:this.onTabchange,
beforerender: this.onBeforeRender,
renderpage:this.onRenderPage
}
});
}, onRenderPage:function (tab,pageID){
console.log('onRenderPage pageID = '+pageID);
}, onBeforeRender:function (tab, eOpts){
console.log("zytab controller start : onBeforeactivate");
var params = eOpts.params;
RetrieveData.putData2Store(CreatePage.getPageId(),CreatePage.getShowCmd());

},
onTabchange: function (tabpanel, tab) {
//var tabs = Ext.ComponentQuery.query('viewport > #zytabpanel');
//vpnconnection = Ext.create('widget.vpnconnection');
//tab.loader.load();
Ext.Ajax.request({
url: './app/view/Dashboard/Dashboard.js',
success: function(response){
var contentPanel = Ext.ComponentQuery.query('viewport > panel[region="center"]');
eval(response.responseText );
debugger;

}
});
}
});


I extend this zytab controller for the view 'VPN.Connection'



Ext.define('zldapp.controller.VPN.Connection', {
extend: 'zldapp.controller.Zytab.Zytab',
views: ['VPN.Connection'],
stores: ['VPN.showPRcontroll', 'VPN.showCryptMap', 'VPN.showAddress', 'VPN.showAddressGrp'],

init: function() {
console.log('controller.VPN.Connection');

this.control();
}
});

Gary Schlosberg
6 Nov 2013, 6:08 AM
What does your app.js look like?

sdd0
6 Nov 2013, 4:47 PM
My app.js is as below:



Ext.Loader.setConfig({enabled:true});


Ext.application({
name: 'zldapp',
requires: [
'zldapp.common.Common',
'zldapp.common.RetrieveData',
'zldapp.common.CreatePage'
],
controllers:['Treepanel.Treepanel','Viewport.Viewport','Zytab.Zytab'],
autoCreateViewport: true,
launch: function() {
_zldAppGlobal = this;
}
});