【问题标题】:JQuery GetOrgChart - Boxescolor and URLJQuery GetOrgChart - Boxescolor 和 URL
【发布时间】:2015-06-28 21:47:49
【问题描述】:

我正在尝试 GetOrgChart 并且有一个问题,可以更改框颜色,但是我没有找到基于过滤器更改框颜色的方法(即,如果您是男孩,则框为蓝色和粉红色女孩们)。我知道事件 renderBoxContentEvent 但我无法找到一种方法来使用它来修改框的颜色

提前谢谢你!

【问题讨论】:

    标签: orgchart


    【解决方案1】:

    查看以下演示:http://www.getorgchart.com/Demos/Box-Color

    它准确地展示了你想要实现的目标

    【讨论】:

    • 谢谢我看到了演示,但是代码看起来像boxesColor: [ { id: 2, color: "blue" }, { id: 3, color: "lightteal" } ] 在示例中 id 是硬编码的,我无法想办法用条件替换 ie id:2,例如(简化)if sex=male then color is blue else if sex=female then color is pink else color is grey`
    • 我试过这样的东西` setBoxColor: function( sender, args ) { if (args.Sex == "Male") args.boxesColor.push({ id: args.id, color: "蓝色的”}); },` 没有成功,我想不出一种方法来根据过滤器设置框的颜色
    【解决方案2】:

    我遇到了同样的问题并做了一个解决方法,这肯定不是很好,但它正在工作。

    设置 2 个数组,根据 data.Sex 的结果收集 id。

    var warr = new Array(); // array for the women
    var marr = new Array(); // array for the men
    
    $('#people').getOrgChart({
                renderBoxContentEvent: function( sender, args ) {
                    if (args.data.Sex == "Female") {warr.push(args.id);}
                    if (args.data.Sex == "Male")  {marr.push(args.id);}
                },  
                    primaryColumns: ["Name"],
                    editable: true,
                    dataSource: [
                { id: 1, parentId: null, Name: "Amber McKenzie", Sex : "Female"},
                { id: 2, parentId: 1, Name: "Ava Field", Sex : "Female"},
                { id: 3, parentId: 1, Name: "Ben Johnson", Sex : "Male"}]
    
                });
    
                // now loop through the arrays to color the boxes   
                for (var i = 0; i < warr.length; i++) {$("#people").getOrgChart("setBoxColor",warr[i],"lightgreen");} // girls green
                for (var i = 0; i < marr.length; i++) {$("#people").getOrgChart("setBoxColor",marr[i],"lightblue");} // men blue
            });
    

    【讨论】:

      【解决方案3】:

      在演示底部(http://www.getorgchart.com/Demos/Box-Color),有 JQuery 代码来设置数据源中特定索引的框颜色:

      $("#people").getOrgChart("setBoxColor", 6, "green");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-02
        • 1970-01-01
        • 1970-01-01
        • 2012-02-27
        • 1970-01-01
        相关资源
        最近更新 更多