可拖曳的树

原创
2013/06/12 16:26
阅读数 67
树组件的拖拽

tree-17

设置的代码如下 详细:http://www.360ui.net

var setting1 = {

    edit: {

        enable: true,

        showRemoveBtn: false,

        showRenameBtn: false

    },

    callback:{

        beforeDrag: beforeDrag1,

        beforeDrop: beforeDrop1

    }

};

 

 

var zNodes1 = [

    { id:1,   parentId:0, name:"随意拖拽 1", open:true},

    { id:11,  parentId:1, name:"随意拖拽 1-1"},

    { id:12,  parentId:1, name:"随意拖拽 1-2", open:true},

    { id:121, parentId:12, name:"随意拖拽 1-2-1"},

    { id:122, parentId:12, name:"随意拖拽 1-2-2"},

    { id:123, parentId:12, name:"随意拖拽 1-2-3"},

    { id:13,  parentId:1, name:"禁止拖拽 1-3", open:true, drag:false},

    { id:131, parentId:13, name:"禁止拖拽 1-3-1", drag:false},

    { id:132, parentId:13, name:"禁止拖拽 1-3-2", drag:false},

    { id:133, parentId:13, name:"随意拖拽 1-3-3"},

    { id:2,   parentId:0, name:"随意拖拽 2", open:true},

    { id:21,  parentId:2, name:"随意拖拽 2-1"},

    { id:22,  parentId:2, name:"禁止拖拽到我身上 2-2", open:true, drop:false},

    { id:221, parentId:22, name:"随意拖拽 2-2-1"},

    { id:222, parentId:22, name:"随意拖拽 2-2-2"},

    { id:223, parentId:22, name:"随意拖拽 2-2-3"},

    { id:23,  parentId:2, name:"随意拖拽 2-3"}

];

 

//实现树的拖拽

function beforeDrag1(treeId, treeNodes) {

    for (var i = 0, l = treeNodes.length; i < l; i++) {

        if(treeNodes[i].drag === false) {

            return false;

        }

    }

    return true;

}

 

//实现树的拖放

function beforeDrop1(treeId, treeNodes, targetNode, moveType) {

    return targetNode ? targetNode.drop !== false : true;

}

展开阅读全文
打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部