2013-04-05 71 views
0

我正在使用jstree jquery插件來顯示和管理樹。這是JSON數據:jquery/jstree最初顯示子節點

0: {id:35, name:amrs trade, parent_id:null} 
1: {id:36, name:trips, parent_id:35} 
2: {id:37, name:tribute, parent_id:null} 
3: {id:38, name:music, parent_id:null} 
4: {id:39, name:recordings, parent_id:38} 
5: {id:40, name:live shows, parent_id:38} 
6: {id:41, name:others, parent_id:null} 
7: {id:42, name:investments, parent_id:null} 
8: {id:43, name:gold & silver, parent_id:42} 
9: {id:44, name:debentures, parent_id:42} 
10: {id:46, name:production, parent_id:35} 
11: {id:54, name:real estate, parent_id:42} 

,我使用創建渲染我的樹:

$("#incomeCategoryTree").jstree({ 
    "json_data" : { 
     "data" : income, 
     "progressive_render" : true 
    }, 
    "plugins" : [ "themes", "json_data" ] 
}) 

我想要顯示的樹,有它的一些選擇的節點最初打開(在現在,只顯示頂層,隱藏所有非頂層節點)。我可以在json上面添加什麼選項來使jstree最初擴展選定的節點?

回答

0

狀態:open/closed這項工作:

0: {id:35, name:amrs trade, parent_id:null, state:open} 
1: {id:36, name:trips, parent_id:35} 
2: {id:37, name:tribute, parent_id:null} 
3: {id:38, name:music, parent_id:null} 
4: {id:39, name:recordings, parent_id:38} 
5: {id:40, name:live shows, parent_id:38} 
6: {id:41, name:others, parent_id:null} 
7: {id:42, name:investments, parent_id:null, state:closed} 
8: {id:43, name:gold & silver, parent_id:42} 
9: {id:44, name:debentures, parent_id:42} 
10: {id:46, name:production, parent_id:35} 
11: {id:54, name:real estate, parent_id:42}