我正在尝试使用此组织结构图库 http://www.getorgchart.com
使用很少的节点可以完美地工作,但是,当我尝试加载整个组织(大约 1100 个具有多个嵌套级别的主题)时,我收到此控制台错误:
未捕获类型错误:无法读取 null 的属性“_aZ”
并且无法显示图表。
任何帮助将不胜感激。 谢谢!
最佳答案
经过一番研究,我解决了这个问题。
问题是你需要先由 parent 订购你的数据源(文档中没有说明);让我们在在客户端上初始化在线演示中看一下这个示例:
$('#people').getOrgChart({
theme: "vivian",
primaryColumns: ["name", "title", "phone", "mail", "postcode"],
imageColumn: "image",
gridView: true,
dataSource:[
{ id: 1, parentId: null, name: "Elizabeth Horton", title: "Founder", phone: "(03) 9252 4642" , image: "images/f-46.jpg", mail:"elizabeth.horton@live.com", postcode: "PH2 2SR" },
{ id: 2, parentId: 1, name: "Emily Horton", title: "Fork lift operator", phone: "(08) 9015 4407", image: "images/f-45.jpg", mail:"emily.horton@live.com", postcode: "BA5 0AP" },
{ id: 3, parentId: 1, name: "Robert Nolan", title: "Blockmason", phone: "(02) 6747 7998", image: "images/f-41.jpg", mail:"robert.nolan@live.com", postcode: "BH9 4NG" },
{ id: 4, parentId: 1, name: "Callum Anderson", title: "System operator", phone: "(03) 5314 0473", image: "images/f-43.jpg", mail:"callum.anderson@live.com", postcode: "HR6 8ZF" },
{ id: 5, parentId: 4, name: "Courtney John", title: "System operator", phone: "(03) 5314 0473", image: "images/f-42.jpg", mail:"courtney.john@live.com", postcode: "OL4 6WF" }
]
});
如果我将组织负责人伊丽莎白·霍顿 (Elizabeth Horton) 的顺序更改为数据源的底部,如下所示:
$('#people').getOrgChart({
theme: "vivian",
primaryColumns: ["name", "title", "phone", "mail", "postcode"],
imageColumn: "image",
gridView: true,
dataSource:[
{ id: 2, parentId: 1, name: "Emily Horton", title: "Fork lift operator", phone: "(08) 9015 4407", image: "images/f-45.jpg", mail:"emily.horton@live.com", postcode: "BA5 0AP" },
{ id: 3, parentId: 1, name: "Robert Nolan", title: "Blockmason", phone: "(02) 6747 7998", image: "images/f-41.jpg", mail:"robert.nolan@live.com", postcode: "BH9 4NG" },
{ id: 4, parentId: 1, name: "Callum Anderson", title: "System operator", phone: "(03) 5314 0473", image: "images/f-43.jpg", mail:"callum.anderson@live.com", postcode: "HR6 8ZF" },
{ id: 5, parentId: 4, name: "Courtney John", title: "System operator", phone: "(03) 5314 0473", image: "images/f-42.jpg", mail:"courtney.john@live.com", postcode: "OL4 6WF" },
{ id: 1, parentId: null, name: "Elizabeth Horton", title: "Founder", phone: "(03) 9252 4642" , image: "images/f-46.jpg", mail:"elizabeth.horton@live.com", postcode: "PH2 2SR" }
]
});
我收到此错误:
Uncaught TypeError: Cannot read property '_aZ' of null
所以我希望回答我自己的问题可以帮助其他有同样问题的人。
干杯!
关于javascript - 使用orgchart时出错: Cannot read property '_aZ' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32207534/