Skip to content

MatthiasRMS/vue-tree-view

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree View Component (for Vue)

GitHub version Bower version

Tree view component for Vue Js.

Demo

Demo (with Bootstrap)

Demo (with customized CSS)

Package index

Installation

Several installation options are available:

Usage

Add the following resources for the tree view to function correctly.

<!-- Required Stylesheets -->
<link href="[component path]/dist/vue.tree-view.min.css" rel="stylesheet">

<!-- Required Javascript -->
<script src="vue.js"></script>
<script src="[component path]/dist/vue.tree-view.min.js"></script>

Add the component in your vue view.

<!-- Assuming your view app is APP. -->
<body id="app">

    <treeview :value.sync="value"
        :model="treeData"
    ></treeview>

</body>

Where:

  • model is the tree data within your vue model.
  • value is the selected value in the tree you want to bind with your model.

Props

List of available props to use in component:

Prop Data Type Default Description
model Array [] Tree data.
value String or Numeric Tree's selected value.
class String CSS Class to add to treeview.
children String nodes Name of the property in the tree that contains child nodes.
labelname String label Name of the property in the tree that contains the node's label.
valuename String value Name of the property in the tree that contains the node's value.

Usage example (Demo):

<body id="app">

    <treeview :value.sync="id"
        :model="users"
        class="form-control"
        labelname="name"
        valuename="id"
    ></treeview>

</body>
new Vue({
    el: '#app',
    data: {
        id: undefined, // Binded to component.
        users: [
            {
                name: 'John',
                id: 1
            },
            {
                name: 'Jane',
                id: 2
            }
        ],
    }, 
});

Events

List of available events to use in component:

Event Passes Description
treeview_click node: Selected node Triggered when a node is clicked.

Usage example (Demo):

new Vue({
    el: '#app',
    events: {
        'treeview_click': function(node) {
            // TODO my code here
            console.log(node.label);
            console.log(node.value);
        }
    }, 
});

License

Copyright (c) 2016 10Quality. Under MIT License.

About

Tree View component for Vue JS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 45.9%
  • HTML 37.3%
  • CSS 16.8%