2014-06-18 1 views
1

나는 최근에 프로젝트를 위해 jstree를 사용하기 시작했다. 나는 jstree 웹 사이트의 문서에보고하고 아주 간단한 나무와 함께 올라와있다 :이 코드를 실행하면, 내가 가진 전부 그 자체에 링크 된 글 머리에 'P1'은새로운 jstree 기초

<div id="jstree_test"></div> 
<script> 
$(function() { 

$('#jstree_test').jstree({ 
    core: { 
     data: [ 
       { 
        id: 'parent1', 
        parent: '#', 
        text: 'p1' 
       }, 
       { 
        id: 'child1', 
        parent: 'parent1', 
        text: 'c1' 
       }, 
       { 
        id: 'child2', 
        parent: 'parent1', 
        text: 'c2' 
       }, 
       { 
        id: 'child3', 
        parent: 'parent1', 
        text: 'c3' 
       } 
     ] 
    } 
}); 

});    
</script> 

입니다. 내 원하는 코드는 단순히 3 개의 자식 c1, c2 및 c3을 가진 p1입니다. 어떤 도움이라도 대단히 감사하겠습니다. 시간

답변

0

에 대한

덕분에 개체에 특정 노드에 상태 속성을 추가합니다. DEMO

-

$('#jstree_test').jstree({ 
    core: { 
     data: [ 
      { 
       id: 'parent1', 
       parent: '#', 
       text: 'p1', 
       'state' : { 
         'opened' : true, 
         'selected' : true 
       } 
      }, 
      { 
       id: 'child1', 
       parent: 'parent1', 
       text: 'c1' 
      }, 
      { 
       id: 'child2', 
       parent: 'parent1', 
       text: 'c2' 
      }, 
      { 
       id: 'child3', 
       parent: 'parent1', 
       text: 'c3' 
      } 
    ] 
} 
}); 

는 jsbin에서 데모를 감안할 때