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

treeview-react-bootstrap

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treeview-react-bootstrap

Nice, easy to use component to displaying tree structures, made with React and Twitter Bootstrap

  • 0.4.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
203
increased by65.04%
Maintainers
1
Weekly downloads
 
Created
Source

treeview-react-bootstrap

Nice, easy to use component to displaying tree structures, made with React and Twitter Bootstrap
Based on jonmiles/react-bootstrap-treeview, but provides a set of additional useful features

Try it :

You can see an example here

Installation

 
  npm install treeview-react-bootstrap --save
 

Usage

Import
 
  TreeView = require('treeview-react-bootstrap').default;
 
es2015 style import
 
  import TreeView from 'treeview-react-bootstrap';
 
Render
in *.jsx :
 
  React.render(
    <TreeView data={data} />,
    document.getElementById('treeview')
 );
 
in *.js :
 
  React.render(                
	React.createElement(TreeView, {data: data}),
	document.getElementById('treeview')
  );
 
Options
ParamDescriptionDefault
data[Object]
No default, expects data

This is the core data to be displayed by the tree view
undefined
selectableBoolean flag

Allow to select nodes by clicking on them
true
allowNewBoolean flag

Allow to add new nodes using add button
false
removableBoolean flag

Allow to remove existing nodes using remove button
false
onNodeAddedCallback

Function that is called after node has been added
undefined
onNodeRemovedCallback

Function that is called after node has been removed
undefined
onDoubleClickCallback

Function that is called after node has been removed
undefined

This treeview component also supports all options defined for base component.

Data structure

"data" property must be provided for treeview to work. It should be an array of objects(nodes).

Node object structure.

{
  text: String,
  nodes: [Node]
}

Node options

The following properties are defined to allow node level overrides, such as node specific icons, colours and tags.

ParamDescriptionDefault
textString
Mandatory

The text value displayed for a given tree node, typically to the right of the nodes icon.
undefined
iconString

The icon-class set to icon on given node, typically displayed to the left of the text.
"glyphicon glyphicon-stop"
colorString

The foreground color used on a given node, overrides global color option.
#428bca
backColorString

The background color used on a given node, overrides global color option.
undefined
hrefString

Used in conjunction with global enableLinks option to specify anchor tag URL on a given node.
undefined
stateObject

Describes a node's initial state.
node: props.node,
expanded: true
state*.expanded*Boolean

Whether or not a node is expanded i.e. open. Takes precedence over global option levels.
true
state*.selected*Boolean

Whether or not a node is selected.
false
tags[String]

Used in conjunction with global showTags option to add additional information to the right of each node; using Bootstrap Badges
undefined
Example

var data = [
  {
    text: "Parent 1",
    nodes: [
      {
        text: "Child 1",
        nodes: [
          {
            text: "Grandchild 1"
          },
          {
            text: "Grandchild 2"
          }
        ]
      },
      {
        text: "Child 2"
      }
    ]
  },
  {
    text: "Parent 2"
  }
];

Keywords

FAQs

Package last updated on 30 May 2016

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