使dnd更新节点而不是移动节点

时间:2014-07-29 14:01:37

标签: javascript jquery drag-and-drop jstree

我正在尝试使用2个jstree和移动功能。我主要担心的是不是从一个表移动到另一个表的节点,而是将一棵树的节点拖放到另一棵树的顶部,以便更新节点信息(我在后台使用ajax电话)

更新更新的jstree具有类似于此的配置

jQuery(document).ready(function (){

   var current_opperation = '';

jQuery("#tree1")
         .jstree({
                 "core" : {
                                "load_open" : "true"
                                },
                 "crrm" : {
                     "move" : {
                         "check_move" : function (data) {
                                var p = this._get_parent(data.o);
                                   if(!p) return false;
                                            p = p == -1 ? this.get_container() : p;
                                                if(p === data.np) return true;
                                                if(p[0] && data.np[0] && p[0] === data.np[0]) return true;

                                var copy_from_group = data.o.attr("id");
                                var match = copy_from_group.match(/gp_/);
                                }

                        },
                        "create":{
                                "label": "New"
                                },

                  },
                 "dnd" : {
                        "default_position" : "inside"
                        },
                 "types": {
                        "max_depth" : <% $depth %>,
                        'types':{
                        's':{
                                        'icon' :{
                                                'image' : '/icons/s16x16.png',
                                        },
                                },
                        'p': {
                                         'icon' :{
                                                'image' : '/icons/p16x16.png',
                                        },
                                },
                        'q': {
                                         'icon' :{
                                                'image' : '/icons/q16x16.png',
                                        },
                                },
                        'w': {
                                         'icon' :{
                                                'image' : '/icons/w16x16.png',
                                        },

                                },
                        },
                },

                 "plugins" : ["types","dnd","ui","crrm","themes","contextmenu","html_data","checkbox" ]

})
});

从中拖动节点的树具有如下所示的配置:

jQuery(document).ready(function(){

        jQuery("#tree2")
         .jstree({
                 "core" : {
                                "load_open" : "true"
                                },
                 "crrm" : {
                     "move" : {
                         "always_copy" : "multitree",
                         "check_move" : function (data) {

                                 var p = this._get_parent(data.o);
                                   if(!p) return false;
                                            p = p == -1 ? this.get_container() : p;
                                                if(p === data.np) return true;
                                                if(p[0] && data.np[0] && p[0] === data.np[0]) return true;
                                var from = data.o.attr("group");
                                var to = data.r.attr("group");
                                var tocheck  = parseInt(to) + 1;
                                if(from == tocheck)
                                {
                                        return !(data.p === "before" || data.p === "after");
                                }
                                else
                                {
                                        return false;
                                        }

                                }

                        },
                        "create":{
                                "label": "New"
                                },

                  },
                 "dnd" : {
                        "default_position": "inside"
                        },
                 "types": {
                        "max_depth" : 7,
                        },

                 "plugins" : ["types","dnd","ui","crrm","themes","contextmenu","html_data","checkbox" ],
                 "contextmenu" : {'items' : customMenu }


        })
});

我甚至设法确保树不移动节点只更新第一棵树的节点。但我似乎无法删除&#34; X&#34;当jstree不允许您移动节点时显示。我怎么做 。此外,我如何更新只进行一次复制/移动调用,而不是每次节点悬停在节点上时(即次要)

提前致谢

0 个答案:

没有答案