Initialization options
Data type and data source options
Unordered list markup

Current example demonstrates multi level file tree with default options, initialized from an <ul> element. The markup also contains elements in custom styling

  • Expanded folder with children
    • Expanded sub-item
      • Active sub-item (active and focus on init)
      • Basic menu item with HTML support
    • Collapsed sub-item
      • Sub-item 2.2.1
      • Sub-item 2.2.2
  • Menu item with key and tooltip
  • Collapsed folder
    • Sub-item 1.1
    • Sub-item 1.2
  • This is a selected item
  • Document with some children (expanded on init)
    • Document sub-item
    • Another document sub-item
      • Sub-item 2.1.1
      • Sub-item 2.1.2
Load JSON data

In this example multi level file tree initialized from JSON data type and attached to <div> block element. The element itself is empty, all markup comes from json file

Embed JSON data

To embed JSON data in the markup, specify data type via data-type attribute and hide it using .d-none class to avoid flashing of unstyled/unloaded content before initialization

[ {"title": "Expanded folder with children", "expanded": true, "folder": true, "children": [ {"key": "1_2", "title": "Expanded sub-item", "expanded": true, "children": [ {"key": "1_2_1", "title": "Active sub-item (active and focus on init)", "active": true, "focused": true}, {"key": "1_2_2", "title": "Basic <i>menu item</i> with <strong class='fw-semibold'>HTML support</strong>"} ]}, {"key": "1_3", "title": "Expanded sub-item", "children": [ {"key": "1_3_1", "title": "Sub-item 2.2.1"}, {"key": "1_3_2", "title": "Sub-item 2.2.2"} ]} ]}, {"key": "2", "title": "Menu item with key and tooltip", "extraClasses": "has-tooltip", "tooltip": "Look, a tool tip!"}, {"key": "3", "title": "Collapsed folder", "folder": true, "children": [ {"key": "3_1", "title": "Sub-item 1.1"}, {"key": "3_1", "title": "Sub-item 1.2"} ]}, {"key": "4", "title": "This is a selected item", "selected": true}, {"key": "5", "title": "Document with some children (expanded on init)", "expanded": true, "children": [ {"key": "5_1", "title": "Document sub-item"}, {"key": "5_2", "title": "Another document sub-item", "children": [ {"key": "5_2_1", "title": "Sub-item 2.1.1"}, {"key": "5_2_2", "title": "Sub-item 2.1.2"} ]} ]} ]
Drag and drop support

Fancytree supports drag'n'drop of tree nodes based on native HTML5 API. Any element that has the draggable="true" attribute set may be dropped over a Fancytree node

Selectable nodes
Single an multiple selections
Multiple select

This tree has multi selection enabled: a single-click handler selects the node; a keydown handler selects on space. In this mode all nodes have inline checkboxes

Disable selection

You can turn off a node selection by adding .hideCheckbox class to it or disable it using .unselectable class. All other interactions with the node will remain enabled

  • Expanded folder with children
    • Expanded sub-item
      • Active sub-item (active and focus on init)
      • Sub-item with hidden checkbox
    • Collapsed sub-item
      • Sub-item 2.2.1
      • Sub-item 2.2.2
  • Menu item with hidden checkbox
  • Collapsed folder with hidden checkbox
    • Sub-item 1.1
    • Sub-item 1.2
  • This is an unselectable checkbox
  • Document with some children (expanded on init)
    • Checked unselectable document sub-item
    • Another document sub-item
      • Sub-item 2.1.1
      • Sub-item 2.1.2
Tree persistence

Store and restore tree status using cookies or local storage: click, expand or select nodes and reload the page. To see it in action, select or unselect nodes and reload the page

Toggle checkboxes state

Change checkboxes state programmatically using setSelected() parameter with true or false properties. Use Select all checkbox to check or uncheck all nodes

Hierarchical select

Hierarchical multi selection example. A single-click handler selects the node; a keydown handler selects on space. All parent nodes get indeterminate checkbox state

  • Expanded folder with children
    • Expanded sub-item
      • Menu sub-item
      • This is a selected item
    • Collapsed sub-item
      • Sub-item 2.2.1
      • Sub-item 2.2.2
  • Collapsed folder
    • Sub-item 1.1
    • Sub-item 1.2
  • Basic menu item with HTML support
  • Document with some children (expanded on init)
    • Document sub-item
    • Another document sub-item
Single select

Single select example. Although functionality wise there's no other changes, all checkboxes are displayed as radio buttons with corresponding styling. Markup is still the same

Various examples
Fancytree examples with options
Editable nodes

Node titles can be changed via inline editing using dblclick, Shift + click [F2] or Enter (on Mac only). Press Enter or Tab key to save your changes

Child counter

The following example demonstrates optional tiny badges that display count of children elements at parent node. It's controlled by childcounter extension stored in a separate file

Toggle state

This example demonstrates the usage of some Fancytree API functions, such as disabling and enabling file tree. Check Disable checkbox to see it in action

Tree sorting

This example demonstrates a sorting feature of child list by title in 2 ways: full tree and in active nodes only. Set deep option to true to sort all descendant nodes

  • Document with some children (expanded on init)
    • Document sub-item
    • Another document sub-item
      • Sub-item 2.1.1
      • Sub-item 2.1.2
  • Expanded folder with children
    • Expanded sub-item
      • Active sub-item (active and focus on init)
      • Basic menu item with HTML support
    • Collapsed sorting node
      • Sub-item 2.2.1
      • Sub-item 2.2.2
    • Another sortable node
  • This is a selected item
  • Collapsed folder
    • Sub-item 1.1
    • Sub-item 1.2
Table tree
The following example demonstrates rendered tree as a table (aka tree grid) and support keyboard navigation in a grid with embedded input controls. Table functionality is based on Fancytree's table.js extension. The tree table extension takes care of rendering the node into one of the columns. Other columns have to be rendered in the renderColumns event.
# Items Key Like
Activity
New notifications
James has completed the task Submit documents from Onboarding list
2 hours ago
Margo has added 4 users to Customer enablement channel
3 hours ago
Subscription #466573 from 10.12.2021 has been cancelled. Refund case #4492 created
4 hours ago
Older notifications
Nick requested your feedback and approval in support request #458
3 days ago
Mike added 1 new file(s) to Product management project
new_contract.pdf
112KB
1 day ago
All hands meeting will take place coming Thursday at 13:45.
2 days ago
Christine commented on your community post from 10.12.2021
2 days ago
HR department requested you to complete internal survey by Friday
3 days ago
Loading...
Demo configuration
Color mode
Direction
Layouts
Purchase Limitless