Я создал дерево со следующими данными. После этого процесса я сделал процесс перетаскивания между меню. И в результате изменилась структура меню. Я хочу экспортировать новые данные json, которые имеют одинаковую структуру с моими первыми данными. Как я могу получить данные из дерева? Плес помог мне.jstree получить новые данные json от дерева
Я пробовал этот код, но этот экспорт очень сложный json. Я хочу, как мой первый формат данных.
var v = $('#data').jstree(true).get_json();
var mytext = JSON.stringify(v);
alert(mytext);
первое состояние меню:
последнее состояние меню:
// html demo
$('#html').jstree();
// inline data demo
$(function() {
var arrayCollection = [
{"id": "animal", "parent": "#", "text": "Animals"},
{"id": "device", "parent": "#", "text": "Devices"},
{"id": "dog", "parent": "animal", "text": "Dogs"},
{"id": "lion", "parent": "animal", "text": "Lions"},
{"id": "mobile", "parent": "device", "text": "Mobile Phones"},
{"id": "lappy", "parent": "device", "text": "Laptops"},
{"id": "daburman", "parent": "dog", "text": "Dabur Man", "icon": "/"},
{"id": "Dalmation", "parent": "dog", "text": "Dalmatian", "icon": "/"},
{"id": "african", "parent": "lion", "text": "African Lion", "icon": "/"},
{"id": "indian", "parent": "lion", "text": "Indian Lion", "icon": "/"},
{"id": "apple", "parent": "mobile", "text": "Apple IPhone 6", "icon": "/"},
{"id": "samsung", "parent": "mobile", "text": "Samsung Note II", "icon": "/"},
{"id": "lenevo", "parent": "lappy", "text": "Lenevo", "icon": "/"},
{"id": "hp", "parent": "lappy", "text": "HP", "icon": "/"}
];
$('#data').jstree({
'core' : {
'check_callback' : true,
'data' :arrayCollection ,
},
"plugins" : ["dnd","wholerow"]
});
});//function