我正在尝试使用loadFromJSON加载getorgchart,但收到以下消息:“无法读取未定义的属性'children'。这是我的代码:
var peopleElement = document.getElementById("people");
var orgChart = new getOrgChart(peopleElement, {
primaryFields: ["name", "title", "phone", "mail"],
expandToLevel: 100,
layout: getOrgChart.MIXED_HIERARCHY_RIGHT_LINKS
});
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: '@Url.Action("deptosGetOrg", "Deptos")',
success: function (data) {
var model = JSON.stringify({ 'dataSource': data })
orgChart.loadFromJSON(model, true);
}
});
这是ajax请求的结果:
{ id = "58", parentId = null, name = "DIRECCION GENERAL", title = " ,", mail = "[email protected]" }
{ id = "59", parentId = "58", name = "DIRECCION GENERAL ASISTENTE", title = "AP AM ,Nombre", mail = "[email protected]" }
{ id = "60", parentId = "58", name = "DIRECCION DE AUDITORIA INTERNA CORPORATIVA REGIONA", title = " ,", mail = "[email protected]" }
{ id = "61", parentId = "58", name = "DIRECCION COMERCIAL DE PAIS", title = " ,", mail = "[email protected]" }
{ id = "62", parentId = "58", name = "DIRECCION DE COMPRAS Y LOGISTICA REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "63", parentId = "58", name = "DIRECCION DE FINANZAS REGIONAL", title = "AP AM ,Nombre", mail = "[email protected]" }
{ id = "64", parentId = "58", name = "DIRECCION JURIDICA REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "65", parentId = "58", name = "DIRECCION DE SISTEMAS REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "66", parentId = "58", name = "DIRECCION DE SERVICIO AL CLIENTE REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "67", parentId = "58", name = "DIRECCION DE INGENIERIA Y OPERACIONES REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "68", parentId = "58", name = "DIRECCION DE MERCADEO Y COMERCIAL CENTRO AMERICA", title = " ,", mail = "[email protected]" }
{ id = "69", parentId = "58", name = "DIRECCION PROYECTOS Y TECNOLOGIA REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "70", parentId = "58", name = "DIRECCION REC.HUMANOS/REGULACION INTERCON.REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "71", parentId = "58", name = "DIRECCION COMERCIAL SVA REGIONAL", title = " ,", mail = "[email protected]" }
{ id = "72", parentId = "58", name = "DIRECCION VENTAS MERCADO CORPORATIVO", title = " ,", mail = "[email protected]" }
{ id = "76", parentId = "59", name = "GERENCIA DE TIENDAS PROPIAS", title = "AP AM ,Nombre", mail = "[email protected]" }
{ id = "77", parentId = "59", name = "GERENCIA FINANCIERA", title = "AP AM ,Nombre", mail = "[email protected]" }
{ id = "79", parentId = "60", name = "GERENCIA DE ASEGURAMIENTO DE INGRESOS", title = " ,", mail = "[email protected]" }
{ id = "80", parentId = "60", name = "GERENCIA DE AUDITORIA INTERNA", title = "xxxxxxxxxxxxxxxx", mail = "[email protected]" }
{ id = "81", parentId = "60", name = "GERENCIA DE ANALISIS Y RIESGO REGIONAL", title = "xxxxxxxxxxxxxxx", mail = "[email protected]" }
{ id = "82", parentId = "61", name = "GERENCIA DE ESTRATEGIA COMERCIAL", title = "xxxxxxxxxxxx", mail = "[email protected]" }
{ id = "83", parentId = "61", name = "GERENCIA MERCADEO/DESARROLLO COMERCIAL", title = "xxxxxxxxxxxx", mail = "[email protected]" }
{ id = "84", parentId = "61", name = "GERENCIA DE VENTAS INMOBILIARIAS", title = "xxxxxxxxxxxxxxxxxx", mail = "[email protected]" }
{ id = "85", parentId = "61", name = "GERENCIA DE OPERACIONES COMERCIALES PARA DISTRIBUI", title = "xxxxxxxxxxxxxxxxxxx", mail = "[email protected]" }
{ id = "89", parentId = "62", name = "GERENCIA DE COMPRAS", title = " ,", mail = "[email protected]" }
{ id = "90", parentId = "62", name = "GERENCIA DE LOGISTICA REGIONAL", title = "xxxxxx", mail = "[email protected]" }
提前致谢!
最佳答案
删除第二个参数
orgChart.loadFromJSON(model);
这是处理您的数据的示例:http://www.getorgchart.com/Experimental/test24.html