simple tree UI component for Ember. No JQuery. Pure handlebars and recursion.
ember install ember-cli-tree
The only thing you need to care of is how your single tree node looks like. Here is an example tree object:
const treeHead = {
label: '1',
children: [
{
label: '2'
},
{
label: '2',
children: [
{
label: 3
}
]
}
]
}
Simple usage:
- eagerCreate - boolean, determines, how tree is rendered:
- if set to true, the whole tree is placed into DOM upon component's insertion (show/hide is implemented via display: none)
- if set to false, every node is inserted individually lazily upon parent's node expansion (show/hide is implemented via if helper) (Default: true)
- childrenKey - String, the key of children attribute in tree node object (Default: 'children')
- expandEvent - String, event, which causes expanding of node when triggered on ember-tree/trigger-expand component (Default: 'click')
- showOnly - Number, the number of node's children shown by default (Default: undefined)
- showOtherTextFmt - String (format string, see Ember.String.fmt for details), if showOnly is set, the value of this property is the value of link text, clicking on which makes hidden children to be shown, where 1st format parameter - # of children left (Default: 'Show Other %@')
- expandAction - String, name of an action, which handles expansion of sub trees on top level. If defined, node.isExpanded have to be manually set, e. g.
See tests for more.
...
expandActionHander(node, isExpanded){
// some custom handling, then
Ember.set(node, 'isExpanded', isExpanded);
}
...
- add drag and drop
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.