All Projects → phphe → Vue Draggable Nested Tree

phphe / Vue Draggable Nested Tree

Licence: mit
Please use the he-tree-vue, vue-draggable-nested-tree will no longer be maintained.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Draggable Nested Tree

vue-virtualised
Blazing fast scrolling and updating for any amount of list and hierarchical data.
Stars: ✭ 18 (-94.04%)
Mutual labels:  tree-structure, vue-component, treeview
Pbtreeview
An UITreeView implementation from UITableView that Apple missed in its UIKit framework. And it is in pure Swift.
Stars: ✭ 128 (-57.62%)
Mutual labels:  tree-structure, treeview
Graphview
Android GraphView is used to display data in graph structures.
Stars: ✭ 918 (+203.97%)
Mutual labels:  tree-structure, treeview
Unity-IMGUI-TreeView
Simple Tree View implementation for IMGUI (Editor GUI) in Unity. Includes a special type for working with asset paths, but base data structure and view can be easily extended to support anything.
Stars: ✭ 73 (-75.83%)
Mutual labels:  tree-structure, treeview
Treeview
An android tree structure view with high performance and rich features
Stars: ✭ 429 (+42.05%)
Mutual labels:  tree-structure, treeview
Bosket
Collection of tree view components for front-end frameworks. 🌳
Stars: ✭ 457 (+51.32%)
Mutual labels:  tree-structure, treeview
Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (-49.67%)
Mutual labels:  tree-structure, treeview
react-treefold
A renderless tree component for your hierarchical React views
Stars: ✭ 37 (-87.75%)
Mutual labels:  tree-structure, treeview
react-folder-tree
A versatile react treeview library that supports custom icons and event handlers
Stars: ✭ 56 (-81.46%)
Mutual labels:  tree-structure, treeview
vue-drag-zone
Drag Zone component for @vuejs
Stars: ✭ 127 (-57.95%)
Mutual labels:  vue-component, draggable
Bstreeview
Bootstrap Treeview, A very simple plugin to build a basic and elegant Treeview with bootstrap 4. See the demo:
Stars: ✭ 308 (+1.99%)
Mutual labels:  tree-structure, treeview
Perfect-Server-Side-Swift iOS-App
A family tree API server implementation with iOS client. Server has been implemented with Perfect: Server-Side Swift And iOS client is in pure Swift.
Stars: ✭ 15 (-95.03%)
Mutual labels:  tree-structure, treeview
Vue Draggablecal
Not your ordinary datepicker. A Vuejs draggable date selector with a fresh responsive design, mobile ready and 0 dependencies, 17kb gzipped
Stars: ✭ 79 (-73.84%)
Mutual labels:  vue-component, draggable
Ete
Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
Stars: ✭ 506 (+67.55%)
Mutual labels:  tree-structure, treeview
Gijgo
Gijgo - Free Javascript Controls
Stars: ✭ 424 (+40.4%)
Mutual labels:  draggable, treeview
react-tree
Hierarchical tree component for React in Typescript
Stars: ✭ 174 (-42.38%)
Mutual labels:  tree-structure, treeview
he-tree-vue
A draggable sortable vue tree component, with dragging placeholder, types definition.
Stars: ✭ 123 (-59.27%)
Mutual labels:  draggable, treeview
GraphView
Android GraphView is used to display data in graph structures.
Stars: ✭ 952 (+215.23%)
Mutual labels:  tree-structure, treeview
Data-structures
Data Structures in Java
Stars: ✭ 13 (-95.7%)
Mutual labels:  tree-structure
Laravel Nestedset
Effective tree structures in Laravel 4-5
Stars: ✭ 3,045 (+908.28%)
Mutual labels:  tree-structure

Please use the he-tree-vue, vue-draggable-nested-tree will no longer be maintained.

请使用新发布的he-tree-vue, vue-draggable-nested-tree 将不再维护.

Please use the he-tree-vue, vue-draggable-nested-tree will no longer be maintained.

请使用新发布的he-tree-vue, vue-draggable-nested-tree 将不再维护.

Please use the he-tree-vue, vue-draggable-nested-tree will no longer be maintained.

请使用新发布的he-tree-vue, vue-draggable-nested-tree 将不再维护.

vue-draggable-nested-tree vue可拖拽树, 可跨树拖拽

这是可拖拽树组件. 此组件没有css, 您需要自己添加您喜欢的样式, 参考demo, 只有几个样式, 不难. 此组件不负责节点的具体渲染, 暴露了一个节点渲染插槽, 请参考demo自行渲染.
This is a draggable tree component. This component does not have css, you need to add your style refer to demo. The demo style is less, not difficult. This component doesn't render node. It exposes a node rendering slot. Please refer to the demo for rendering.

touch

已支持简单触摸(单点).
Support touch(single point).

Donation / 打赏

Paypal | Alipay/支付宝 | Wechat/微信

Indexes

install

npm i vue-draggable-nested-tree

usage

import

import {DraggableTree} from 'vue-draggable-nested-tree'
// vue-draggable-nested-tree contains Tree, TreeNode, DraggableTree, DraggableTreeNode
// import the component and register it as global or local component

data

data: [
  {text: 'node 1'},
  {text: 'node 2'},
  {text: 'node 3 undraggable', draggable: false},
  {text: 'node 4'},
  {text: 'node 4 undroppable', droppable: false},
  {text: 'node 5', children: [
    {text: 'node 1'},
    {text: 'node 2', children: [
      {text: 'node 3'},
      {text: 'node 4'},
    ]},
    {text: 'node 2 undroppable', droppable: false, children: [
      {text: 'node 3'},
      {text: 'node 4'},
    ]},
    {text: 'node 2', children: [
      {text: 'node 3'},
      {text: 'node 4 undroppable', droppable: false},
    ]},
    {text: 'node 3'},
    {text: 'node 4'},
    {text: 'node 3'},
    {text: 'node 4'},
    {text: 'node 3'},
    {text: 'node 4'},
    {text: 'node 3'},
    {text: 'node 4'},
  ]},
]

template

Tree(:data="data" draggable crossTree)
  div(slot-scope="{data, store, vm}")
    //- data is node
    //- store is the tree
    //- vm is node Vue instance, you can get node level by vm.level
    template(v-if="!data.isDragPlaceHolder")
      b(v-if="data.children && data.children.length" @click="store.toggleOpen(data)") {{data.open ? '-' : '+'}} 
      span {{data.text}}

template for old browsers(eg: IE)

//- slot-scope="{data, store, vm}" may not work in old browsers, replace with slot-scope="slot"
Tree(:data="data" draggable crossTree)
  div(slot-scope="slot")
    //- data is node
    //- store is the tree
    //- vm is node Vue instance, you can get node level by vm.level
    template(v-if="!slot.data.isDragPlaceHolder")
      b(v-if="slot.data.children && slot.data.children.length" @click="slot.store.toggleOpen(slot.data)") {{slot.data.open ? '-' : '+'}} 
      span {{slot.data.text}}

api

The 'store' is the tree vm

Tree props

Noraml - Tree props
// base tree
data: {}, // type Array
indent: {default: 16},
activatedClass: {default: 'active'},
openedClass: {default: 'open'},
space: {default: 10}, // space between node, unit px
// draggable tree
preventSelect: {default: true}, // if to prevent drag handler text be selected when drag, excluding input and textarea
getTriggerEl: {type: Function}, // get the el trigger drag, default is node self. arguments(nodeVm)
draggable: {}, // is the tree draggable, default false
droppable: {default: true}, // is the tree droppable, default true
crossTree: {}, // can a node of the tree be dragged into other tree, or receive other tree node

Hooks - Tree props
ondragstart: {type: Function}, // hook. return false to prevent drag. arguments(node, draggableHelperInfo)
ondragend: {type: Function}, // hook. return false to prevent drop. arguments(node, draggableHelperInfo)

draggableHelperInfo

{event, options, store}

Tree properties

// base
rootData, // generated by tree
// draggable
dplh, // drag placeholder. globally unique.
trees, // array, all trees in the app. globally unique.

Tree events

// store is the tree vm
drag(node), // on drag start.
drop(node, targetTree, oldTree), // after drop.
change(node, targetTree, oldTree), // after drop, only when the node position changed
nodeOpenChanged(node) // on a node is closed or open
  • targetTree and oldTree are tree vm.
  • oldTree is available only when cross tree. Otherwise null.
  • if cross tree, both targetTree and oldTree will emit drop and change.

Tree methods

pure(node, withChildren, after)
/*
pure
return a node data without runtime properties.(!: property which starts with '_' will be removed)
withChildren: optional. after: Function, optional
the code about after(t is computed node data):
if (after) {
  return after(t, node) || t
}
return t
*/
getNodeById(id)
getActivated()
getOpened()
activeNode(node, inactiveOld)
toggleActive(node, inactiveOld)
openNode(node, closeOld)
toggleOpen(node, closeOld)
// follow methods are easy, so I paste their soure code
getPureData(after) { return this.pure(this.rootData, true, after).children } // after: Function, optional
deleteNode(node) { return hp.arrayRemove(node.parent.children, node) }
// add node: like array. eg: node.children.push(newNodeData)
// update node: just assign to the node properties directly
isNodeDraggable(node)
isNodeDroppable(node)

node properties

// base
_id
_vm
parent
children: [],
open,
active: false,
style: {},
class: '',
innerStyle: {},
innerClass: '',
innerBackStyle: {},
innerBackClass: {},
// draggable
draggable // default true. Please check 'draggable & droppable' below
droppable // default true. Please check 'draggable & droppable' below
isDragPlaceHolder

node deep properties example

node._vm // vm
node._vm.level // 节点层级, 只读
node._vm.store // tree
node.parent._vm // parent node vm
node._vm.store

other

demo css

.he-tree{
  border: 1px solid #ccc;
  padding: 20px;
  width: 300px;
}
.tree-node{
}
.tree-node-inner{
  padding: 5px;
  border: 1px solid #ccc;
  cursor: pointer;
}
.draggable-placeholder{
}
.draggable-placeholder-inner{
  border: 1px dashed #0088F8;
  box-sizing: border-box;
  background: rgba(0, 136, 249, 0.09);
  color: #0088f9;
  text-align: center;
  padding: 0;
  display: flex;
  align-items: center;
}

examples

clone the package, and

npm install
npm run dev

draggable & droppable

A node is default draggable and droppable. You can set draggable and droppable property of a node. The another way is listen event 'drag', traverse all data to set draggable or droppable property.

Traverse tree

Recommend to use my other library tree-helper. It has 2 traverse methods: depthFirstSearch, breadthFirstSearch.

draggable library

draggable-helper is my another library for drag. And it also is using by this component. You can use it to help you drag functions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].