Flexible AJAX enabled Tree View Plugin For jQuery Flextree - Download Flexible AJAX-enabled Tree View Plugin For jQuery - Flextree

Download Flexible AJAX-enabled Tree View Plugin For jQuery – Flextree

Posted on

This time I will share jQuery Plugin and tutorial about Flexible AJAX-enabled Tree View Plugin For jQuery – Flextree, hope it will help you in programming stack.

Flexible AJAX enabled Tree View Plugin For jQuery Flextree - Download Flexible AJAX-enabled Tree View Plugin For jQuery - Flextree
File Size: 610 KB
Views Total: 3958
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Flextree is a simple, flexible jQuery plugin used for rendering a dynamic, highly customizable tree structure from external JSON data via AJAX request.

Features:

  • Drag and drop supported.
  • Collapsible and expandable like an accordion.
  • Supports checkboxes with 3 check stats.
  • Custom template for each node.
  • Lots of customization options and API.

Basic usage:

1. Include the jQuery Flextree’s CSS files in the header that will provide the primary CSS styles for the tree view.

1 <link rel="stylesheet" href="flextree.css">

2. Include jQuery library together with the flextree.js and flextree.components.js at the bottom of the webpage.

1 <script src="jquery.js"></script>
2 <script src="flextree.js"></script>
3 <script src="flextree.components.js"></script>

3. Prepare your JSON data:

01 [
02   {
03     "id": "0",
04     "parent_id": null,
05     "categoryName": "Python",
06     "items": [
07       "Python Introduction",
08       "Web2py",
09       "Django",
10       "Flask",
11       "GUI",
12       "Network"
13     ]
14   },
15   {
16     "id": "1",
17     "parent_id": null,
18     "categoryName": "J2EE",
19     "items": [
20       "JSP",
21       "Maven",
22       "Spring",
23       "MyBaits",
24       "Hibernate"
25     ]
26   }
27 ]

4. Render a tree view using $.flextree function:

  • dataSource: JSON data array
  • template: custom template
  • args: args.id {string}, args.parentId {string}, args.correctParent {boolean}, args.collapsible {boolean}, args.collapseEvent {string}, args.exclusiveNode {boolean}, args.fixDblClickBug {boolean}, args.onBind {function (data {object}, i {number}, node {element})}
  • onBind: same as args.onBind, but when specify both, this will override args.onBind
1 $.flextree.tree(dataSource, template, args, onBind)

5. Global settings.

01 // padding-left for child nodes
02 $.flextree.global.padding='1em';
03  
04 // global template
05 var template = '...';
06 $.flextree.global.template = template;
07  
08 // global args
09 var args = {
10     ...
11 };
12 $.flextree.global.args = args;

6. API.

01 // get the parent
02 $().treeParent()
03  
04 // get the ancestors
05 $().treeParents()
06  
07 // get the children
08 $().treeChildren()
09  
10 // get the descendant
11 $().treeFind()
12  
13 // get the siblings
14 $().treeSiblings()
15  
16 // get the next node
17 $().treeNext()
18  
19 // get all the next nodes
20 $().treeNextAll()
21  
22 // get the previous node
23 $().treePrev()
24  
25 // get all the previous nodes
26 $().treePrevAll()
27  
28 // get the node
29 $().treeNode()
30  
31 // get the root
32 $().treeRoot()
33  
34 // get all nodes
35 $().treeAll()
36  
37 // collapse the node
38 $().treeActivate()
39  
40 // expand the node
41 $().treeExpanded()

This awesome jQuery plugin is developed by zhang-rf. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net