I have a simple codes below to build a hierarchy tree from a JSON data file. Error appears in dhtmxtree_json.js file. Is there something I missed in my codes or a bug in dhtmlxtree_json extension?
Thanks,
Brian
JSON DATA:
{ label: ‘name’,
identifier: ‘name’,
items: [
{ name:‘Students’, type:‘cat’,
children: [
{ name:‘Vinod’, type:‘st’ },
{ name:‘Suman’, type:‘st’ },
{ name:‘Deepak’, type:‘st’ }
]
},
{ name:‘Fruits’, type: ‘cat’,
children: [
{ name:‘Apple’, type:‘fr’ },
{ name:‘Mango’, type:‘fr’ },
{ name:‘Graps’, type:‘fr’,
children: [
{ name:‘Sweets’, type:‘gr’ },
{ name:‘Sour’, type:‘gr’ },
{ name:‘Salt’, type:‘gr’ }
]
}
]
},
{ name:‘Vegetables’, type: ‘cat’},
{ name:‘Education’, type:‘cat’}
]
}
JSON data , used in your case, missed “id” property for each item.
Expected JSON data
{
items: [
{
id:“some1”,
text: ‘Students’,
type: ‘cat’,
children: [
{
id:“some2”,
text: ‘Vinod’,
type: ‘st’
},
{
id:“some3”,
text: ‘Suman’,
type: ‘st’
},
{
id:“some4”,
text: ‘Deepak’,
type: ‘st’
}
]
}
]
}
Hi,
After I added the ID’s to the json data file per your suggestion, I got this error: "Error Type: DataStructure. Description: XML reffers to not existing parents"
Thanks,
Brian
Working sample attached to email.
If problem still occurs for you - please provide exact snippet of data, which cause problem in your case ( you can send it directly to support@dhtmlx.com )
1243945883.zip (38.4 KB)