{
"data": [
{
"id": 122,
"parentId": 0,
"name": " 桌子凳子",
"description": "AA",
"image": "",
"order": 0,
"extraData": null,
"subCategories": [
{
"id": 123,
"parentId": 122,
"name": "电脑桌",
"description": "1903",
"image": "",
"order": 0,
"extraData": null,
"subCategories": [
{
"id": 568,
"parentId": 123,
"name": "儿童桌子",
"description": "6416",
"image": "",
"order": 0,
"extraData": null,
"subCategories": []
}
]
},
{
"id": 512,
"parentId": 122,
"name": "儿童桌子",
"description": "6416",
"image": "",
"order": 0,
"extraData": null,
"subCategories": []
}
]
}
],
"count": 1
}
json?但好像格式不对!
例子1:从json文件加载数据
$(function() {
$("#demo1").jstree({
"json_data" : {
"ajax" : {
"url" : "_json_data.json",
"data" : function(n) {
alert(n);
return {
id : n.attr ? n.attr("id") : 0
};
}
}
},
"plugins" : [ "themes", "json_data" ]
});
});
例子2:从jsp或servlet加载数据
$("#demo2")
.jstree(
{
"json_data" : {
"data" : [ {
"data" : {
"title" : "A node"
},
"attr" : {
"id" : 0
},
"state" : "closed"
}, {
"attr" : {
"id" : "li.node.id"
},
"data" : {
"title" : "Long format demo",
"attr" : {
"href" : "#"
}
}
} ],
"ajax" : {
"url" : "../../watch/admin_tree_xml.jsp",
"data" : function(n) {
return {
id : n.attr ? n.attr("id") : 0,
rand : new Date().getTime()
};
}
}
},
"plugins" : [ "themes", "json_data"]
});