All Projects → justinchmura → js-treeview

justinchmura / js-treeview

Licence: MIT License
TreeView implemented with vanilla JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to js-treeview

bs-breakpoints
A plugin which detect Bootstrap 4 breakpoints and emit when there is a change
Stars: ✭ 22 (-56.86%)
Mutual labels:  vanilla-javascript
genmusic
Generative Music- a stochastic modal music generator
Stars: ✭ 17 (-66.67%)
Mutual labels:  vanilla-javascript
react-super-treeview
👏 Finally, a React Treeview component which is customizable on every level
Stars: ✭ 98 (+92.16%)
Mutual labels:  treeview
react-treefold
A renderless tree component for your hierarchical React views
Stars: ✭ 37 (-27.45%)
Mutual labels:  treeview
twilight-commander
A simple console file manager.
Stars: ✭ 16 (-68.63%)
Mutual labels:  treeview
deni-react-treeview
A modern, themable and configurable treeview for React
Stars: ✭ 48 (-5.88%)
Mutual labels:  treeview
snake-game
Classic snake game built in Vanilla JavaScript using the Canvas API
Stars: ✭ 56 (+9.8%)
Mutual labels:  vanilla-javascript
select2-to-tree
Select2-to-Tree extends Select2 to support arbitrary level of nesting...
Stars: ✭ 71 (+39.22%)
Mutual labels:  treeview
vanilla-js-drawer
A dependency-free Vanilla JS drawer. No dependencies, no automation build tools.
Stars: ✭ 20 (-60.78%)
Mutual labels:  vanilla-javascript
vanillajs-hello
Start a VanillaJS website using WebPack in just 30 seconds: HTML,CSS,Babel,SASS,Bootstrap,Prettier,Gitpod
Stars: ✭ 24 (-52.94%)
Mutual labels:  vanilla-javascript
react-native-nested-listview
A UI component for React Native for representing nested arrays of N levels
Stars: ✭ 163 (+219.61%)
Mutual labels:  treeview
vanilla-js-carousel
Tiny (1Kb gzipped) JavaScript carousel with all the features most of us will ever need.
Stars: ✭ 87 (+70.59%)
Mutual labels:  vanilla-javascript
tabbis.js
Pure vanilla javascript tabs with nesting
Stars: ✭ 44 (-13.73%)
Mutual labels:  vanilla-javascript
QMLTreeView
A TreeView component for QML/QtQuick 2 with a generic TreeModel
Stars: ✭ 21 (-58.82%)
Mutual labels:  treeview
shoot game
🎮 It is a game using HTML5 Canvas and Vanilla JavaScript.
Stars: ✭ 35 (-31.37%)
Mutual labels:  vanilla-javascript
dalted
Image processing web-app for color blindness
Stars: ✭ 17 (-66.67%)
Mutual labels:  vanilla-javascript
sakura
🌸 A javascript plugin to Make it rain sakura petals using CSS animations and requestAnimationFrame (vanilla JS and improved version of jQuery-Sakura).
Stars: ✭ 46 (-9.8%)
Mutual labels:  vanilla-javascript
Border-Radius-Generator
A CSS3 Border Radius Generator; Get the best border-radius playground, with a minimalist design!
Stars: ✭ 19 (-62.75%)
Mutual labels:  vanilla-javascript
Perspective
🖼Parallax scrolling effect. And more.
Stars: ✭ 80 (+56.86%)
Mutual labels:  vanilla-javascript
spider-covid-19-viz-3d
Speedy access to the latest, local COVID-19 data with a familiar interface: the Globe
Stars: ✭ 19 (-62.75%)
Mutual labels:  vanilla-javascript

Vanilla JavaScript TreeView

Build Statusnpm version

A stupid, simple tree view written with vanilla JS. I needed a lightweight control that just displayed data in a tree form and out popped this. I wrote a post on my blog that goes into more depth.

Dependencies

None. I built this using only plain JavaScript so there's no external dependencies. Other than the CSS required for styling.

Example Usage

If used outside of NPM/require, it will attach a global TreeVew object to window. If done using NPM, then it can be included using require like everything else. To install it via NPM:

npm install js-treeview

HTML

<div id="tree"></div>

JavaScript

// NPM
var TreeView = require('js-treeview');

var tree = new TreeView([
    { name: 'Item 1', children: [] },
    { name: 'Item 2', expanded: true, children: [
            { name: 'Sub Item 1', children: [] },
            { name: 'Sub Item 2', children: [] }
        ]
    }
], 'tree');

Options

Name Type Description
data array The array of items to populate the tree with. Each item is required to have a name and a children array. An optional expanded option allows you to default the child to be expanded when created.
id `string object`

Events

Name Arguments Description
expand target - The DOM node that initiated the expand
leaves - Array of leaf DOM nodes under the target
Fires when a leaf is expanded.
expandAll No arguments Fires after the expandAll method is called.
collapse target - The DOM node that initiated the collapse
leaves - Array of leaf DOM nodes under the target
Fires when a leaf is collapsed.
collapseAll No arguments Fires after the collapseAll method is called.
select target - The DOM node selected
data - Data node associated with the selected element
Fires when a outermost leaf is selected. Contains data item of the leaf selected.

Usage

tree.on('select', function (e) {
    console.log(JSON.stringify(e));
});

CodePen Example

License

This plugin is available under the MIT license.

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].