我在使用https://github.com/dabeng/OrgChart的data.php中得到了类似这样的输出
[
{"title":"306","relationship":"30","name":"HARDWARE & ","parentid":"30"},
{"title":"296","relationship":"476","name":"IT DOCUMENTATION","parentid":"476"},
{"title":"596","relationship":"30","name":"MAGANG MIS DEPARTMENT","parentid":"30"},
{"title":"345","relationship":"30","name":"NETWORK SYSTEM STAFF","parentid":"30"},
{"title":"184","relationship":"476","name":"PROGRAM ANALYST","parentid":"476"},
{"title":"46","relationship":"476","name":"PROGRAMMER","parentid":"476"},
{"title":"476","relationship":"30","name":"SOFTWARE DEVELOPMENT ","parentid":"30"},
{"title":"580","relationship":"30","name":"SYSTEM & NETWORK S","parentid":"30"},
{"title":"604","relationship":"580","name":"SYSTEM & SECURITY ","parentid":"580"},
{"title":"48","relationship":"306","name":"TECHNICAL SUPPORT","parentid":"306"}
]
从这个ajax
$('#chart-container').orgchart({
'data' : 'data.php',
'nodeContent': 'title',
'nodeId': 'id',
'exportButton': true,
'exportFilename': 'MyOrgChart'
});
但这不管用吗?非常感谢
发布于 2018-03-22 11:10:44
将'data.php‘替换为json格式的ajax响应。此外,您的关系应该在"111“= "hasParent,hasSibling,hasChildren”的"1/0“中,而不是父母in。
发布于 2020-01-14 11:05:18
最新版本的插件组织结构图可以在幕后将关系属性附加到数据源。因此,您可以删除数据源中的关系字段,并使用json对象来初始化组织结构图,而不是数组。
$('#chart-container').orgchart({
'data' : jsonObj,
'nodeContent': 'title',
'nodeId': 'id',
'exportButton': true,
'exportFilename': 'MyOrgChart'
});
https://stackoverflow.com/questions/48877368
复制相似问题