Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-jstree

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-jstree

a tree plugin for vue2

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-48.64%
Maintainers
1
Weekly downloads
 
Created
Source

vue-jstree

A tree plugin for vue2

tree

DEMO

http://zdy1988.github.io/vue-jstree

NPM

    npm install vue-jstree

ES6

    import VJstree from 'vue-jstree'
    
    new Vue({
      components: {
        VJstree
      }
    })

Setup

    npm install
    npm run dev

Usage

    <v-jstree :data="data" show-checkbox multiple allow-batch whole-row @item-click="itemClick"></v-jstree>
    
    new Vue({
      data: {
        data: [
          {
            "text": "Same but with checkboxes",
            "children": [
              {
                "text": "initially selected",
                "selected": true
              },
              {
                "text": "custom icon",
                "icon": "fa fa-warning icon-state-danger"
              },
              {
                "text": "initially open",
                "icon": "fa fa-folder icon-state-default",
                "opened": true,
                "children": [
                  {
                    "text": "Another node"
                  }
                ]
              },
              {
                "text": "custom icon",
                "icon": "fa fa-warning icon-state-warning"
              },
              {
                "text": "disabled node",
                "icon": "fa fa-check icon-state-success",
                "disabled": true
              }
            ]
          },
          {
            "text": "Same but with checkboxes",
            "opened": true,
            "children": [
              {
                "text": "initially selected",
                "selected": true
              },
              {
                "text": "custom icon",
                "icon": "fa fa-warning icon-state-danger"
              },
              {
                "text": "initially open",
                "icon": "fa fa-folder icon-state-default",
                "opened": true,
                "children": [
                  {
                    "text": "Another node"
                  }
                ]
              },
              {
                "text": "custom icon",
                "icon": "fa fa-warning icon-state-warning"
              },
              {
                "text": "disabled node",
                "icon": "fa fa-check icon-state-success",
                "disabled": true
              }
            ]
          },
          {
            "text": "And wholerow selection"
          }
        ]
      },
      methods: {
        itemClick (node) {
          console.log(node.model.text + ' clicked !')
        }
      }
    })

API

PropsTypeDefaultDescribe
dataArrayset tree data
sizeStringset tree item size , value : 'large' or '' or ''small'
show-checkboxBooleanfalse
whole-rowBooleanfalse
no-dotsBooleanfalse
collapseBooleanfalseset all tree item collapse state
multipleBooleanfalseset multiple selected tree item
allow-batchBooleanfalse
text-field-nameString'text'set tree item display field
value-field-nameString'value'set tree item value field
children-field-nameString'children'set tree item children field
item-eventsObject{}register any event to tree item, example
asyncFunctionasync load callback function , if node is a leaf ,you can set 'isLeaf: true' in data
loading-textString'Loading'set loading text
draggableBooleanfalseset tree item can be dragged , selective drag and drop can set 'dragDisabled: true' and 'dropDisabled: true' , all default value is 'false'
drag-over-background-colorString'#C9FDC9'set drag over background color
klassStringset append tree class

Methods in node.model

MethodParams
addChild(object) newDataItem
addAfter(object) newDataItem, (object) selectedNode
addBefore(object) newDataItem, (object) selectedNode
openChildren
closeChildren

Event

@item-click(node, item, e)

@item-toggle(node, item, e)

@item-drag-start(node, item, e)

@item-drag-end(node, item, e)

@item-drop(node, item, draggedItem, e)

node : current node vue object item : current node data item object e : event

Data Item Optional Properties

NameTypeDefaultDescribe
iconStringcustom icon css class
openedBooleanfalseset leaf opened
selectedBooleanfalseset node selected
disabledBooleanfalseset node disabled
isLeafBooleanfalseif node is a leaf , set true can hide '+'
dragDisabledBooleanfalseselective drag
dropDisabledBooleanfalseselective drop

License

Licensed under the MIT license.

Thanks For jstree's UI

Keywords

FAQs

Package last updated on 20 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc