DynaTree root node null / undefined - children undefined
("#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
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;
I have got the answer:
//node = item which has isFolder() = false, islazy() = false
var topnode = node.parent;
topnode.reloadChildren(function(topnode, isOk){});
You can read the title using:
var rootNode = $("#tree").dynatree("getRoot");
var realRootTitle = rootNode.childList[1].data.title;
精彩评论