【问题标题】:GetOrgChart Expanding nodes in IEGetOrgChart 在 IE 中展开节点
【发布时间】:2018-08-10 13:27:59
【问题描述】:

我在 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

【问题讨论】:

    标签: internet-explorer microsoft-edge expand getorgchart


    【解决方案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
    };
    

    【讨论】:

      猜你喜欢
      • 2017-05-28
      • 2014-06-19
      • 2018-01-30
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多