ajax로 데이터 가져와서 트리 생성하는 방법.
data array에서 data 부분은 트리의 노드가 가지고있어야 할 데이터를 마음대로 넣어줄수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | $.ajax({ ... success: function(data){ var data = new Array(); $.each(data, function(idx, item){ data[idx] = {id:item.id, parent:item.text, type:item.type, data:{a:item.a, b:item.b, ...}}; }); $("#tree").jstree({ core: { data: data //데이터 연결 }, types: { 'default': { 'icon': 'jstree-folder' } }, plugins: ['wholerow', 'types'] }) .bind('loaded.jstree', function(event, data){ //트리 로딩 롼료 이벤트 }) .bind('select_node.jstree', function(event, data){ //노드 선택 이벤트 }) } }); | cs |
'jsTree' 카테고리의 다른 글
[jsTree] 클릭한 node의 id, type 등등 가져오는 방법 (0) | 2016.09.02 |
---|