2011-09-09 88 views
0

我已閱讀dynatree的開發人員提供的示例。其中一個顯示在節點中放置「expand:true」,它顯示從一開始就展開。 我創建SQL查詢dynatree中的展開節點

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」並展開:true。字符串和邏輯

我在做什麼錯?

回答

2

我解決它使用onPostInit功能

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

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

在變量文件夾中,我有希望出現擴大了節點的關鍵。所以我從樹上獲得它。我擴大它和它的父母

3

展開應該是一個布爾值,因此嘗試,而不是"expand":true"expand":"true"

+0

對不起,我沒有把它的職位,但我已經測試過,並沒有工作。 –

0

由我自己解決,或許它可以幫助別人: 得到擴展節點的id像這樣做

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

糾正我,請如果我錯了......