IE中的GetOrgChart扩展节点

时间:2018-08-10 13:28:00

标签: internet-explorer microsoft-edge expand getorgchart

在IE和Edge中,我的节点在当前显示的图表顶部展开时出现问题。

此行为仅在IE和Edge中有效,Chrome和Firefox会按预期显示图表。

var peopleElement = document.getElementById("people");
            var orgChart = new getOrgChart(peopleElement, {

            theme: "monica",
            primaryFields: ["Name", "Title", "Department", "Office", "Email", "Phone", "Mobile"],
            photoFields: ["Image"],
            enableEdit: false,
            enableSearch: true,
            enableMove: true,
            enablePrint: false,
            enableZoomOnNodeDoubleClick: true,
            layout: getOrgChart.MIXED_HIERARCHY_RIGHT_LINKS,
            expandToLevel: 2,
            dataSource: source

1 个答案:

答案 0 :(得分:1)

已在版本2.5.2中修复

此问题是由以下getOrgChart函数引起的:

getOrgChart.util._5 = function (a) {
  var b = a.getAttribute("transform");
  // Chome/FireFox value: matrix(1,0,0,1,265,100)
  // IE value: matrix(1 0 0 1 265 100)
  b = b.replace("matrix", "").replace("(", "").replace(")", "");
  b = getOrgChart.util._zJ(b);
  b = "[" + b + "]";
  // Chrome/Firefox value: [1,0,0,1,265,100]
  // IE Value: [1 0 0 1 265 100]
  b = JSON.parse(b);
  return b
}

缺少逗号会导致解析数组时JSON失败。用下面的代码替换该函数,它应该可以工作。

getOrgChart.util._5 = function (a) {
  var b = a.getAttribute("transform");
  // replace all spaces with commas to ensure compatibility in IE
  b = b.replace("matrix", "").replace("(", "").replace(")", "").replace(/ /g, ",");
  b = getOrgChart.util._zJ(b);
  b = "[" + b + "]";
  b = JSON.parse(b);
  return b
};