【问题标题】:Jstree always_copy not working when copying nodes between trees在树之间复制节点时,Jstree always_copy 不起作用
【发布时间】:2013-01-29 17:21:03
【问题描述】:

我真的陷入了 jstree 问题;我有两棵树,一棵“源”树和一棵“目的地”树。 “源”树是一棵包含节点的扁平树,我希望将这些节点拖到“目标”树上来构建它。但是,在拖动之后,我需要保留这些节点,以便我可以重用它们。现在,如果我在拖动之前和拖动期间按下控制键,它将执行复制功能并离开源节点。但是,我不想让用户这样做;我希望树总是复制。这就是我使用此设置的原因,但它不适用于我的树。任何人都可以帮忙吗?这是导致此问题的代码,减去数据。 谢谢!!

<script type="text/javascript">
    $(function () {
        $("#SourceTree").jstree({
            "json_data": {
                "ajax": {
                    "url": "Home/GetTree",
                    "type": "POST",
                    "contentType": "application/json; charset=utf-8",
                    "dataType": "json",
                    "data": function (n) {
                        var result = "{'id':'" + (n.attr ? n.attr("id").replace("node_", "") : "0") + "'}";                            
                        return (result);
                    }
                }
            },
            "crrm": {
                "move": {
                    "always_copy": "multitree",
                    // Do not allow a node move within this tree
                    "check_move": function () {
                        return false;
                    },
                }
            },
            "plugins": ["themes", "json_data", "ui", "types", "crrm", "dnd"]
        })

        $("#DestinationTree").jstree({
            "json_data": {
                "ajax": {
                    "url": "Home/GetTree",
                    "type": "POST",
                    "contentType": "application/json; charset=utf-8",
                    "dataType": "json",
                    "data": function (n) {
                        var result = "{'id':'" + (n.attr ? n.attr("id").replace("node_", "") : "0") + "'}";
                        return (result);
                    }
                }
            },
            "plugins": ["themes", "json_data", "ui", "types", "dnd", "crrm"]
        })
    });

</script>

【问题讨论】:

    标签: jquery-plugins jstree drag-and-drop


    【解决方案1】:

    好的,我通过大量试验和错误想通了: 源代码树必须具有: 1) "dnd" & "crrm" 插件就像例子一样 2) move.check_move 函数必须和上面一样存在 3)我们不需要move.always_copy,删除这个,这里不需要。

    目标树必须具有: 1) "dnd" & "crrm" 插件就像例子一样 2) 需要在此处添加 crrm.move.always_copy:true。 “crrm”:{ “移动”: { “always_copy”:真 } },

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      相关资源
      最近更新 更多