Code Monkey home page Code Monkey logo

bootstrap-treepanel's Introduction

#Bootstrap Tree Panel A simple tree view plugin for Bootstrap

DEMO

##Requirements

##Usage ###1. resources reference:

<link href="bootstrap.min.css" rel="stylesheet" />
<link href="bootstrap-treepanel.css" rel="stylesheet" />

<script src="jquery-2.1.0.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="bootstrap-treepanel.js"></script>

###2. define a holder:

<div id="tree" class="list-group"></div>

###3. duang duang duang basic usage may looks like this:

var options = {
            valueField: 'number',
            displayField: 'name',
            childNodesField: 'nodes',
            data: '[{ "number": 101, "name": "Top 1" }, { "number":102, "name":"Top 2", "nodes":[{ "number":201, "name":"Second 1", "nodes": [{ "number": 301, "name": "Third 1" }] }, {"number":202, "name":"Second 2"}] }]'
};
var treePanel = $("#tree").treePanel(options);

##Options options is an object for initialization function, that allow you to customise treepanel's default UI & behaviour.

###data
JSON array string of objects, to display the treepanel.
Type: String
IsRequire: true
Default:none

###displayField property name of object in data, property value will display on treepanel.
Type: String
IsRequire: true
Default:none

###valueField property name of object in data, property value should unique the object. like ID.
Type: String
IsRequire: true
Default:none

###childNodesField property name of object in data, property value should be a JSON array of object's child nodes.
Type: String
IsRequire: true
Default:none

###expandDepth sets the number of levels deep the treepanel will be expanded to by default.
Type: Integer
IsRequire: false
Default: 1

###expandIcon sets the icon to be used on an expandable tree node.
Type: String
IsRequire: false
Default: glyphicon-chevron-down

###collapseIcon sets the icon to be used on an collapsed tree node.
Type: String
IsRequire: false
Default: glyphicon-chevron-right

###hasBorder sets whether or not the treepanel has a border.
Type: Boolean
IsRequire: false
Default: true

##Methods Methods provide a way of interacting with the plugin programmatically. you can control the treepanel via invoke method.

all methods 'node' parameter accepts node or nodeId.

###add(node, [parent], [index]) add a new tree node to treepanel.

treePanel.add('{ "number": 103, "name": "Top 3" }');

###update(node) update a tree node which valueField equal to parameter one.

treePanel.update({ number: treePanel.selectedNode.number, name: 'hi' });

###move(node, [parent], [index]) move a tree node.

treePanel.move('201', '101');

###remove(node) remove a tree node.

treePanel.remove(treePanel.selectedNode)

triggers onNodeDisSelected event, if removed node is current selected one or child.

###expand(node) expand a given tree node if it's expandable.

treePanel.expand('102');

###collapse(node) collapse a given tree node if it's collapseable.

treePanel.collapse({ number: 102 });

###select(node) selects a given tree node.

treePanel.select({ number: 102 });

###disSelect([node]) disselect a given tree node, otherwise disselect current selected node.

treePanel.disSelect();

##Events you can bind to event then you can respond to changes by using options callback handler.

$('#tree').treePanel({
    onNodeSelected: function(event, node){
        alert(node.name);
    }
});

###onNodeSelected(event, node) a tree node is selected.

###onNodeDisSelected(event, node) a tree node is disselected.

##License New BSD License

Copyright (c) 2014, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of vigo nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bootstrap-treepanel's People

Contributors

xzoth avatar

Watchers

James Cloos avatar sence leuy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.