("#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...)

所以我愿意:

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

title = null

...好,所以我尝试:

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

无法阅读未定义的财产“标题”

如果我只是:

alert(node);

我得到:

Dynatreenodeu003Clocation.92> :'第一个位置'

所以...?

既然我在问,请在游戏机中:

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

?

有关的?

Uncaught TypeError: Cannot read property 'parentNode' of null
ra
有帮助吗?

解决方案

rootnode是(不可见的)系统root和 rootNode.data.title 未设置。由于node.getChildren()返回列表,因此应该是

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

其他提示

我有答案:

//node = item which has isFolder() = false, islazy() = false

var topnode = node.parent;
topnode.reloadChildren(function(topnode, isOk){});

您可以使用以下方式阅读标题:

var rootNode = $("#tree").dynatree("getRoot");  
var realRootTitle = rootNode.childList[1].data.title;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top