PDA

View Full Version : targetNode is undefined



silcreval
9 Feb 2011, 12:31 AM
I have a treepanel which is embedded in a tabpanel. On the first render I get the
message

targetNode is undefined

targetNode.appendChild(this.wrap); ext-all-debug.js (line 35452)

On subsequent clicks on the treepanel I get

uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLUListElement.appendChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://localhost/ext/ext-all-debug.js :: anonymous :: line 35452" data: no]

There is nothing weird about the tree, and in fact it works fine in a Ext.Window

var my_tab_panel = new Ext.tree.TreePanel({
title:'User',
useArrows:true,
containerScroll:true,
autoScroll:true,
//animate:true,
//enableDD:true,
border:false,
loader: {
dataUrl: 'files.php',
baseParams: {
cmd: 'get',
path: '/'
}
},
root: {
text: '/',
draggable: false,
//expanded: true,
id:'/'
}
});



but I need to put the treepanel in a tabpanel which I do using

var tabs = new Ext.TabPanel({
defaults : {
autoScroll : true
},
activeTab: 0,
items:[
my_tab_panel
]
});

Any ideas? I've been stuck on this for a few weeks.

silcreval
9 Feb 2011, 12:32 PM
It looks like it might be a render issue - ie its attempting to render the tree
before the data is available. However - setting expand=false doesnt seem
to fix this. I guess there is still a request being made.

I found a similar thread in the Ext 2.x help from 2008 which unfortunately
had no solution either - the error message was slightly different - but it
was a tree embedded in another container.

http://www.sencha.com/forum/showthread.php?29765-quot-targetNode-has-no-Properties-quot-in-Treepanel-wrapped-in-namespace-called-from-viewport

johnathanhebert
9 Feb 2011, 1:35 PM
I copied your code into its own page and did not see the error. The full HTML page is below. After loading the page, I called tabs.render(Ext.getBody()) with no errors, and I see the tab panel and the tree with one node



<html>
<head>
<link rel="stylesheet" type="text/css" href="ext-3.3.1/resources/css/ext-all.css"/>
<script type="text/javascript" src="ext-3.3.1/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="ext-3.3.1/ext-all-debug-w-comments.js"></script>
<script>

var my_tab_panel = new Ext.tree.TreePanel({
title:'User',
useArrows:true,
containerScroll:true,
autoScroll:true,
//animate:true,
//enableDD:true,
border:false,
loader: {
dataUrl: 'files.php',
baseParams: {
cmd: 'get',
path: '/'
}
},
root: {
text: '/',
draggable: false,
//expanded: true,
id:'/'
}
});
var tabs = new Ext.TabPanel({
defaults : {
autoScroll : true
},
activeTab: 0,
items:[
my_tab_panel
]
});

</script>
</head>
<body></body>
</html>

silcreval
9 Feb 2011, 2:33 PM
Thanks for trying. I'm wondering if my php script is not delivering the right info. It works fine stand alone, but once its part of a larger app I get issues. Mmm.

silcreval
9 Feb 2011, 2:41 PM
Agreed - I just tried the code and called it manually from the console it works OK. In my app its part of an Ext.Window and the error does occur during the render. Is there some way I can delay the automatic rendering?

johnathanhebert
9 Feb 2011, 3:01 PM
For TabPanel, there is a deferredRender config option...

silcreval
10 Feb 2011, 12:18 AM
deferredRender is true by default - interestingly - if I set it to 'false' - the treepanel goes into an infinite loop continually loading the remote data.

silcreval
10 Feb 2011, 12:23 AM
Uugh, after trawling through masses of code - it turned out to be a stray getRootNode().expand(true) call
in the parent window. This was effectively attempting to render the tree before the data was loaded.