Coder Social home page Coder Social logo

m-thalmann / treejs Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 19.0 38 KB

A simple JavaScript library, to display a TreeView like in the windows filebrowser

Home Page: https://prod.thalmann.it/treejs/demo.html

License: MIT License

JavaScript 92.13% CSS 7.87%
javascript tree-structure treeview vanilla-javascript

treejs's People

Contributors

m-thalmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

treejs's Issues

Problem with Bootstrap Modal?

There is any problem using this script with a container inside a bootstrap modal? Because i am trying to make it working, but I cannot.
Thanks and great work!

Question: how to use node events?

Assigning a callback to a "select", or "click" events makes the callback function fire for all nodes during initial load, then doesn't react to clicks/selection.
What am I doing wrong?

child = new TreeNode(value);
child.on('select', console.log(value));
a.addChild(child);

HTML tags in the node name

The HTML tags are not escaped in the node's name.

If it is intended, an option to turn on encoding should be added.
If it is not intended and encoding will be added, an option to turn it off should be added too.

Node Searching

Hi

Awesome work..

Q1. Is it possible to search for a node by a path e.g. a\b\c?
Q2. Is it possible to feed this a JSON schema that has parent & child relationships?

Thanks.

Empty folders

Could you please add an option to a TreeNode to make it explicitly a folder, not a leaf/file? If it is an empty folder, it will be displayed as a leaf/file instead of a folder that is empty.

Unable to get parent/root node using node.getRoot() method

var node = new TreeNode("parent")
var childNode = new TreeNode("child Node")

childNode.getRoot()

I am trying to get the parent node using this method but getting a node instead.
I want to get the value of parent node.
Please help.

Full path on node click (Related to issue #8)

I'm trying to modify your example in 'issue #8' with the aim of producing a string containing the whole path from root to the clicked node, hence for my modification I was hoping to get the string "root - 1 - 1.1".
The only difference between your test in 'issue #8' and mine is within your "on/select" function (see mine below). However I don't manage to get it to run properly. The fist alert, only showing the selected folder ("1.1"), pops up alright. But the rest of the alert's are ignored, so I'm surely doing something wrong (no exeption's are thrown though). After "countless" trial/errors I'm running out of ideas what to try next. Do you have the possibility to point me in the good direction?

n11.on('select', function (e) {
alert(e);
var mySelNode = tree.getSelectedNodes();
alert("1");
path.setPath(root, mySelNode);
alert("2");
path.getPath();
alert("3");
alert(path.toString());
})

Invalid condition for non-string user objects

In the constructor of TreeNode, the check for the type of userObject (is it string or an object with a toString function) is wrong.

Currently if the userObject is a string, it checks if it has a toString function (it does).
If the userObject is not a string, it errors, without checking the toString function.

It should look like this:
if(typeof userObject !== "string" && typeof userObject.toString !== "function")

Hide root

Could you please add the option to the TreeView to hide the root element?

Sometimes displaying a single root element will just create unnecessary indentation. It would look better if all the children of the root are on the first level, not the second level under the root element.

This should be an option, so it can be turned on on demand.

pop tree with Hash ?

can we make tree from hash JSON ? like :

{name: "root", childs: [{name: "node1"}, {name: "node2", childs: [...]}]

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.