PDA

View Full Version : lookupReference



Chris Wallace
3 Mar 2015, 6:41 PM
Receiving lookupReference Uncaught TypeError: undefined is not a function in version list below with basic kitchen sink example. Am I missing something?



#Tue, 05 Aug 2014 19:25:52 -0700


version.major=5
version.minor=0
version.build=1255
version.revision=1189
version.release=5.0.1255
version.full=5.0.1255.${version.revision}
git.current.hash=2852ec9b146a917f790d13cfa9b9c2fa041fccf8


version.patch=1




var tabPanel = this.lookupReference('ProcessTablSideBar'),
counter = ++this.counter,
html = 'html',
tab = tabPanel.add({
title: 'Tab ' + counter,
html: html
});


tabPanel.setActiveTab(tab);

evant
3 Mar 2015, 7:28 PM
Are you saying that this.lookupReference isn't a function, or the result it returns is null?

Chris Wallace
3 Mar 2015, 7:30 PM
Looks like not a function:
Uncaught TypeError: undefined is not a functionMyTaskListController.js?_dc=1425439673732:31 Ext.define.onOpenProcessRowUpdateactionEvent.js?_dc=1425439673748:387 fireEventDomain.js?_dc=1425439673749:116 Ext.define.dispatchBase.js?_dc=1425439673733:1255 Ext.Base.Base.addMembers.callParentComponent.js?_dc=1425439673740:39 Ext.define.dispatchEventDomain.js?_dc=1425439673749:296 prototype.doFireEventObservable.js?_dc=1425439673738:587 fireEventArgsObservable.js?_dc=1425439673738:540 fireEventMPRApplicatoin.js?_dc=1425439673732:153 config.items.items.items.items.items.columns.items.handlerUtil.js?_dc=1425439673738:110 Ext.apply.callbackAction.js?_dc=1425439673737:398 Ext.define.processEventTable.js?_dc=1425439673745:1228 Ext.define.processEventEvent.js?_dc=1425439673748:387 fireObservable.js?_dc=1425439673738:654 doFireEventEventDomain.js?_dc=1425439673749:293 prototype.doFireEventObservable.js?_dc=1425439673738:587 fireEventArgsObservable.js?_dc=1425439673738:540 fireEventTable.js?_dc=1425439673735:2406 Ext.define.processItemEventView.js?_dc=1425439673745:613 Ext.define.processUIEventView.js?_dc=1425439673745:562 Ext.define.handleEventEvent.js?_dc=1425439673748:387 fireDom.js?_dc=1425439673733:360 Ext.define.fireDom.js?_dc=1425439673733:332 Ext.define.publishDom.js?_dc=1425439673733:391 Ext.define.doDelegatedEventDom.js?_dc=1425439673733:372 Ext.define.onDelegatedEventFunction.js?_dc=1425439673733:145 Ext.Function.ExtFunction.bind.method

Chris Wallace
3 Mar 2015, 7:32 PM
Sone additional information is I am trying to do this in a controller:

Ext.define('App.controller.MyTaskListController', {
extend: 'Ext.app.Controller',

ivanhu
4 Mar 2015, 1:58 AM
Chris, I'm afraid the Ext.app.Controller indeed has no lookupReference method, only the ViewController has. At least that's how I see it in the API docs.

Chris Wallace
4 Mar 2015, 4:01 AM
If I place into my View instead I get past the the function is not found, but tabPanel is null in the
var tabPanel = this.lookupReference('ProcessTabSideBarRef');



xtype: 'tabpanel',
reference: 'ProcessTabSideBarRef',
height: 500,
id: 'ProcessTabSidebar',
itemId: 'ProcessTabSidebar',
activeTab: 0,
tabPosition: 'left',
items: [
{
xtype: 'panel',
layout: 'column',
title: 'Tab 1',
items: [
{
xtype: 'container',
height: 500,
width: 850
},
{
xtype: 'container',
height: 500,
width: 310
}
]
},
{
xtype: 'panel',
title: 'Tab 2'
},
{
xtype: 'panel',
title: 'Tab 3'
}
],
tabBar: {
xtype: 'tabbar'
}




handler: function(view, rowIndex, colIndex, item, e, record, row) {
alert('action fired');
//this.fireEvent( 'updateaction', view, rowIndex, colIndex, item, e, record, row);
var tabPanel = this.lookupReference('ProcessTabSideBarRef');
counter = ++this.counter;
var html = 'html';
console.log(tabPanel);
tab = tabPanel.add({
// we use the tabs.items property to get the length of current items/tabs
title: 'Tab ' + (tabPanel.items.length + 1),
html : 'Another one'
});


tabPanel.setActiveTab(tab);
},

Chris Wallace
4 Mar 2015, 4:38 AM
I was able to get the Tab to Add by Creating it in the ViewController as opposed to the View itself or a Controller. I based the add on a ViewControllerEvent a Button in the View and ran the original code.

ivanhu
5 Mar 2015, 1:35 AM
Of course it is null - the View must be a reference holder for that to work. It becomes that by either assigning a controller to it (controller config property), or by using the referenceHolder config property. Please note also, reference holders see their subtree, but the lookup stops at any other reference holder (embedding them is not possible). See the Ext.container.Container for more info.

And just for the record - if you see the source of the ViewController, it defines the function for convenience but simply delegates the call to its associated View.