PDA

View Full Version : Controller Question



stratboogie
29 Sep 2011, 7:08 PM
Hello,
I am trying to load to add a tab to a tab panel after another tab is rendered. I can load the tab using the add method. When i give the xtype of the view it creates and loads the tab. THen I want to fire an event on the on the views controller. I am requiring this views controller at the start of the app. For some reason none of the controllers events are firing. My code is below. Any reason as to why?

view:


Ext.define("Vertical.view.tab.Member", {
extend: "Ext.grid.Panel",
alias: "widget.member",
title: 'Member',
requires: [
"Vertical.model.Member"
],
border: false,
closable: true,
loadMask: true,
id: "MemberTab",
tbar: [
{ xtype: "button", icon: "images/browse/add.png", tooltip: "Add" },
{ xtype: "button", icon: "images/browse/edit.png", tooltip: "Edit" }
],
columns: [
{ dataIndex: "PersonName", header: "Name" },
{ header: "Visitation/Notes", dataIndex: "VisitationHTML", sortable: false, width: 60 },
{ dataIndex: "Age", header: "Age" },
{ dataIndex: "DOB", header: "DOB", xtype: "datecolumn" },
{ dataIndex: "JoinDate", header: "JoinDate", xtype: "datecolumn" },
{ dataIndex: "SalvationDate", header: "SalvationDate", xtype: "datecolumn" },
{ dataIndex: "BaptismDate", header: "BaptismDate", xtype: "datecolumn" }
],
formWindowName: "Member",
store: { model: "Vertical.model.Member", pageSize: 200, remoteSort: true, buffered: true, sorters: [{ property: "LastName"}] }
});


controller:


Ext.define("Vertical.controller.tab.Member", {
extend: "UX.app.BrowseController",
views: ["Vertical.view.tab.Member"],
refs: [
{ ref: "tabPanel", selector: "viewport > tabpanel" },
{ ref: "member", selector: "viewport > tabpanel > member" }
],
init: function () {
this.control({
"member": {
bind: function() {

},
afterlayout: function (container, layout, eOpts) {

}
},
"member > toolbar > button[tooltip=Add]": {
click: this.handleRecord
}
});
}
});



calling code:

var tabPanel = this.getTabPanel();
var newTab = tabPanel.add({ xtype: "member", title: "Member", closable: true });
newTab.fireEvent("bind", newTab, {});


Thanks
Timothy

stratboogie
30 Sep 2011, 4:04 AM
Any suggestions?
It is almost like there is not a controller attached to the view. The controller I want attached is:
Vertical.controller.tab.Member
Do i need to specify that at the creation of the view? I dont on the other views I have created

lucasguaru
30 Sep 2011, 5:39 AM
I don't see any problem in your code.

Did you added the controller to your application?


Ext.application({
name : 'Vertical',
appFolder : 'js',

controllers: [
'Vertical.controller.tab.Member'
],

launch : function() {
...
}
});

nextSTEP
30 Sep 2011, 5:58 AM
You don't need the prefix in controller declaration, because it's prepended automatically.


controllers: [
'tab.Member'
],

Maybe that's the problem because the prefix occurs twice.

stratboogie
30 Sep 2011, 6:53 AM
I don't see any problem in your code.

Did you added the controller to your application?


Ext.application({
name : 'Vertical',
appFolder : 'js',

controllers: [
'Vertical.controller.tab.Member'
],

launch : function() {
...
}
});


Yes, I have it in the required section of my app.js (application).

stratboogie
30 Sep 2011, 6:54 AM
You don't need the prefix in controller declaration, because it's prepended automatically.


controllers: [
'tab.Member'
],

Maybe that's the problem because the prefix occurs twice.

Are you suggesting to remove it from the required section?

lucasguaru
30 Sep 2011, 7:17 AM
Try change the controller that you extend just to make sure


extend: "UX.app.BrowseController"

To:


extend : 'Ext.app.Controller'

nextSTEP
30 Sep 2011, 7:24 AM
Are you suggesting to remove it from the required section?

No, just for "controllers" or any other ones. Defining it in "requires" requires you to specify the full name.