PDA

View Full Version : Ext.TreePanel get a node.id to an other panel



Loader
9 Mar 2010, 2:05 PM
Hi communety,

I'll write en littel DataExploer to learn moare about ExtJS.
It's a nice framework to develp WebAps :)

But now I've a questsion ..

How I can get the id of an selected node global
hear a part of my code


//BaumVerzeichniss
var tree = new Ext.tree.TreePanel({
itemId: 'Files',
region: 'west',
split: true,
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,

// auto create TreeLoader
dataUrl: 'get-nodes.php',

root: {
nodeType: 'async',
text: 'test', draggable: false,
id: 'test'
}


});

tree.getRootNode().expand();
tree.on('click', getNodeID);
//My problem hear
var FileName;


function getNodeID(node) //Funktion ermittelt selected node
{


if(tree.getSelectionModel().isSelected(node))
{

addTab(node.id,grid);

FileName = node.id;


}

}

var ShowPanel = new Ext.Panel(
{
title: 'Vorschau',
ItemId: 'Vor',
region: 'south',
width:450,
height:150,
autoLoad: FileName
});

// Panel for the west
var nav = new Ext.Panel({
title: 'FileTree',
region: 'west',
split: true,
width: 200,
collapsible: true,
margins:'3 0 3 3',
cmargins:'3 3 3 3',
items: [tree]
});



var win = new Ext.Window({
title: 'File-Maneger',
closable:false,
width:700,
height:500,
plain:true,
layout: 'border',
draggable: true,

items: [nav, tabs,ShowPanel]
});
I'll put the node.id in to the global var FileName the function getNodeID but it dosn't work if i crade an alert outside the function alert(FileName) I geht undefined ...
how I can fix this?