DynaTree在页面渲染上显示Null根

时间:2012-03-09 20:33:33

标签: jquery json dynatree

有人可以帮我解释一下吗?

我无法弄清楚为什么有一个空根为我返回的JSON对象呈现。子项存在于JSON和渲染的js中。

<ul class="dynatree-container">
<li class="dynatree-lastsib">
<span class="dynatree-node etc">
<span class="dynatree-expander"></span>
<span class="dynatree-icon"></span>
    *<a class="dynatree-title" href="#">null</a>*
</span>
    <ul style="">
        <li class="">
        <span class="dynatree-node etc">
        </li>
        <li class="">
            <span class="dynatree-node etc">
        </li>
        <li class="">
        <li class="">
        <li class="">
        <li class="">
        <li class="dynatree-lastsib">
    </ul>
 </li>
</ul>

这是一个截断的(用于空格)返回的JSON对象:

  "children": [
    {
      "key": "0",
      "title": "new  2.txt",
      "isFolder": false,
      "isLazy": false,
      "activate": false,
      "focus": true,
      "expand": true,
      "select": false,
      "hideCheckbox": false,
      "unselectable": false,
      "icon": "images/word.gif"
    },
    {
      "key": "0",
      "title": "tmp001.xls",
      "isFolder": false,
      "isLazy": false,
      "activate": false,
      "focus": true,
      "expand": true,
      "select": false,
      "hideCheckbox": false,
      "unselectable": false,
      "icon": "images/word.gif"
    },
    {
      "key": "0",
      "title": "new  4.txt",
      "isFolder": false,
      "isLazy": false,
      "activate": false,
      "focus": true,
      "expand": true,
      "select": false,
      "hideCheckbox": false,
      "unselectable": false,
      "icon": "images/word.gif"
    }
  ]

这是我的javascript:

  <script>
    $(function(){
    $("#tree").dynatree({
        rootVisible:true,
        title:"Queue",
        rootCollapsible: false,
        selectionVisible: true,
        initAjax: {
            url: 'userProjectQueue.ge',
            cache:false
        },
    onActivate: function(node) {
      $("#echoActive").text(node.data.title + "(" + node.data.key + ")");
    },
    onDeactivate: function(node) {
      $("#echoActive").text("-");
    },
    dnd: {
      onDragStart: function(node) {

        logMsg("tree.onDragStart(%o)", node);
        if(node.data.isFolder)
          return false;
        return true;
      },
      onDragStop: function(node) {
        logMsg("tree.onDragStop(%o)", node);
      }
    }
  });

由于

1 个答案:

答案 0 :(得分:0)

最新版本不再支持rootVisible / rootCollapsible(系统根目录始终处于隐藏状态)。你也不应该传递相同的密钥(虽然可以省略它们。)