PDA

View Full Version : TreePanel Error : Uncaught TypeError: Cannot call method 'substring' of undefined



talha06
19 Nov 2011, 12:28 PM
Hi everyone,

I've a problem while rendering TreePanel. I'm using MVC structure, here's my definition:
(By the way I don't use dynamic loading, included ext-all-debug.)

Menu - Model

Ext.define('RIA4.model.Menu', { extend : 'Ext.data.Model',
idProperty : 'menuId',
fields : [
{ name : 'menuId', type : 'int' },
{ name : 'menuName', type : 'string' },
{ name : 'sourcePath', type : 'string' },
{ name : 'active', type : 'boolean', defaultValue : true },
{ name : 'leaf', type : 'boolean' }
]
});


TreeStore

Ext.define('RIA4.store.Menus', { extend : 'Ext.data.TreeStore',
model : 'RIA4.model.Menu',
proxy : {
type : 'ajax',
api : {
read : 'menu/view.ajax'
},
reader : {
type : 'json',
root : 'data',
successProperty : 'success'
}
},
autoLoad : true
});

TreePanel

Ext.define('RIA4.view.menu.MenuTree', { extend : 'Ext.tree.Panel',
alias : 'widget.menutree',
//requires : [],
title : 'Menu List',
store : 'Menus',
rootVisible : false,
root : {expanded: true, text: "", "data": []}
});

I'll be happy if someone can help me?
Thanks in advance..

mitchellsimoens
19 Nov 2011, 1:08 PM
So what is happening? When do you get this error?

talha06
19 Nov 2011, 1:12 PM
Thanks for quick reply mitchell.

When I try to render treepanel, I get the error I wrote in title :
Uncaught TypeError: Cannot call method 'substring' of undefined

flanders
20 Nov 2011, 2:43 AM
I think Mitchell was referring to some attempt at debugging the error. Personally I see this error a lot when trying to use lazy instantation and the corresponding class is not loaded. (Or i forgot to add 'widget.' to the alias ;))

What if you look up a stacktrace of the exception? What part of your own code is it origination from? Does the stacktrace include methods related to lazy instantation?

talha06
20 Nov 2011, 5:40 AM
Here's the full stacktrace, waiting urgent helps.. :s


Uncaught TypeError: Cannot call method 'substring' of undefinedExt.ClassManager.parseNamespaceext-all-debug-w-comments.js:6183
Ext.ClassManager.getext-all-debug-w-comments.js:6303
Ext.ClassManager.instantiateext-all-debug-w-comments.js:6596
Ext.ClassManager.instantiateByAliasext-all-debug-w-comments.js:6562
(anonymous function)ext-all-debug-w-comments.js:2448
Ext.define.createext-all-debug-w-comments.js:23703
Ext.define.createComponentext-all-debug-w-comments.js:43386
Ext.define.lookupComponentext-all-debug-w-comments.js:43374
Ext.define.prepareItemsext-all-debug-w-comments.js:43349
Ext.define.addext-all-debug-w-comments.js:43474
Ext.define.addext-all-debug-w-comments.js:43464
Ext.define.initItemsext-all-debug-w-comments.js:43245
Ext.define.initComponentext-all-debug-w-comments.js:43225
Base.callParentext-all-debug-w-comments.js:4800
Ext.define.initComponentext-all-debug-w-comments.js:90330
Ext.define.constructorext-all-debug-w-comments.js:24547
Base.callParentext-all-debug-w-comments.js:4800
Ext.define.constructorext-all-debug-w-comments.js:41907
Ext.Class.newClassext-all-debug-w-comments.js:5372
(anonymous function)
Ext.ClassManager.instantiateext-all-debug-w-comments.js:6634
(anonymous function)ext-all-debug-w-comments.js:2448
Ext.application.launchindex.js:11
Ext.define.onBeforeLaunchext-all-debug-w-comments.js:59353
(anonymous function)ext-all-debug-w-comments.js:59322
isEventext-all-debug-w-comments.js:16834
fireext-all-debug-w-comments.js:16976
Ext.EventManager.onDocumentReadyext-all-debug-w-comments.js:17135
Ext.Loader.onReady.fnext-all-debug-w-comments.js:8079
Ext.Loader.triggerReadyext-all-debug-w-comments.js:8054
(anonymous function)ext-all-debug-w-comments.js:2434
Ext.Loader.requireext-all-debug-w-comments.js:7948
Ext.Loader.triggerReadyext-all-debug-w-comments.js:8048
Ext.Loader.refreshQueueext-all-debug-w-comments.js:7675
Ext.Loader.refreshQueueext-all-debug-w-comments.js:7706
Ext.Loader.refreshQueueext-all-debug-w-comments.js:7706
Ext.Loader.onFileLoadedext-all-debug-w-comments.js:7998
(anonymous function)ext-all-debug-w-comments.js:2434
Ext.Loader.injectScriptElement.onLoadFnext-all-debug-w-comments.js:7724

flanders
20 Nov 2011, 6:30 AM
Cool! So what does this tell you? What did you do to try and debug the problem?

My still is that you are lazy instantiating a component by an undefined xtype.

I'm not sure, but it looks like you are using dynamic loading as well? So you can lookup which file is loaded (and generating the error)?

talha06
21 Nov 2011, 4:19 AM
ok, caught the problem, forgot to add the component to the controller. Even you don't need to control the component, you should add it to view.

Thanks a lot everyone who took care.. :)