在dynatree中展开节点

时间:2011-09-09 18:37:11

标签: jquery json symfony1 dynatree

我已经阅读了dynatree开发人员提供的示例。其中一个显示在节点中放置“expand:true”,它从头开始展开。 我创建了一个SQL查询

Doctrine_Core::getTable('Folder')
              ->createQuery('f')
              ->select('slug as key, nombre as title,
                IF(id in ('.implode(',',$ancestors_id).'),true,false) as expand,
                true as isFolder,
                level');

并将返回的数组转换为json数组。

[
 {"id":"1","key":"qqwqeqwe","title":"qqwqeqwe","level":"0","expand":"true","isFolder":"1","children":
   [
     {"id":"2","key":"nombre-de-laaa","title":"nombre de laaa","level":"1","expand":"true","isFolder":"1","children":
          [
            {"id":"3","key":"tof","title":"TOF","level":"2","expand":"false","isFolder":"1","children":[]},
            {"id":"4","key":"dddd","title":"dddd","level":"2","expand":"true","isFolder":"1","children":[]}
          ]
     },
     {"id":"5","key":"ffffa","title":"ffffa","level":"1","expand":"false","isFolder":"1","children":[]}
   ]
 }
]

我在想要展开扩展的节点和他们的祖先上放了“expand:true”。但是没有扩大 我尝试将“expand:true”仅放在我想要扩展的节点中,但它也不起作用。  我已经使用expand进行了测试:“true”并展开:true。字符串和逻辑

我做错了什么?

3 个答案:

答案 0 :(得分:3)

展开应该是布尔值,因此请尝试"expand":true而不是"expand":"true"

答案 1 :(得分:2)

我使用onPostInit函数

解决了它
onPostInit: function(isReloading, isError) {
  var node = $("#tree").dynatree("getTree").getNodeByKey(folder);

  node.visitParents (function (node) {
    node.toggleExpand();
  }, true);         
}

在变量文件夹中,我有要展开的节点的键。所以我从树上获得它。我扩展它和它的父母

答案 2 :(得分:0)

由我自己解决,也许它可以帮助他人: 获取扩展节点的id就像这样

onQueryExpand: function(node) {
  var superId = arguments[1].data.key;
}

如果我错了,请纠正我......