Question

I have read the examples provided by the developers of dynatree. In one of them show that putting "expand: true" in a node, it is shown expanded from the beginning. I created a sql query

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');

and converts the returned array in a json array.

[
 {"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":[]}
   ]
 }
]

I put "expand: true" on the node i want to appear expanded and their ancestors. But is not expanded.
I tried putting the "expand: true" only in the node i want to be expanded but it does not work either. I've tested with expand: "true" and expand: true. Both String and logical

What am I doing wrong?

Was it helpful?

Solution 2

I solved it using the onPostInit function

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

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

In the variable folder, I have the key of the node that I want to appear expanded. So I obtain it from the tree. And I expands it and its parents

OTHER TIPS

Expand should be a boolean, so try "expand":true instead of "expand":"true"

Solved by myself, perhaps it can helps others : to get the id of the expanded node do it like this

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

Correct me please if I'm wrong...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top