DynaTree root node null / undefined - children undefined

Earls picture Earls · Dec 30, 2010 · Viewed 8.4k times · Source
("#tree").dynatree({                
minExpandLevel: 1,              
//persist: true,                
children: [{"title":"First Location",
"isFolder":true,
"expand":true,
"key":"location.92",
"icon":"location.gif",
"children":[{"title":"<span class='assetType'>First Location Child<\/span>",
"key":"locationid=92&typeid=1",
"expand":true,
"icon":"equipment.gif",
"children":[ (etc...)

So I do:

var rootNode = $("#tree").dynatree("getRoot");
var title = rootNode.data.title;

title = null

... ok, so I try:

var rootNode = $("#tree").dynatree("getRoot");
var node = rootNode.getChildren();
var title = node.data.title;

Cannot read property 'title' of undefined

If I just:

alert(node);

I get:

DynaTreeNode<location.92>: 'First Location'

So...?

And since I'm asking, in console:

jquery.dynatree.min.js:710:49:53.215 - Option 'title' is no longer supported.

?

Related?

Uncaught TypeError: Cannot read property 'parentNode' of null
ra

Answer

mar10 picture mar10 · Dec 31, 2010

rootNode is the (invisible) system root and rootNode.data.title is not set. Since node.getChildren() returns a list, it should be

var rootNode = $("#tree").dynatree("getRoot");
var nodeList = rootNode.getChildren();
var title = nodeList[0].data.title;