can you provide some demo codes
I use ember-simple-tree in my project,but it not works,so I hope you can provide some demo codes
+1 for some demo code. I also tried something simple and it didn't work.
Second that, working demo example is definitely needed. I tried the simplest template as outlined in documentation {{x-tree model=tree}} where tree property is plain static object in my component copied from documentation as well and nothing is rendered except empty <ul id="ember1767" class="tree-branch ember-view"><!----></ul> element.
EDIT: It looks that all that's needed is to make the input model tree an array because this addon recursively iterates from the outermost to innermost children.
Sorry for the (very) late reply. I've submitted a pull request with a fixed demo example and a few new features (added to the readme as well). There is also an added utility for converting a flat array of models to a valid tree (the models must have a 'parentId') and vice versa.
If someone has a simple example app using this component, we can add it as an example... Otherwise I believe the examples in the readme should are sufficient. Is there something else you'd like to see in the documentation?
I got it to work. First make sure you added it in your package.json or cli with yarn like yarn add ember-simple-tree. Restart your server.
- In your controller define the
treevalue. This needs to be replace with your actual tree model (computed prop etc). Add this property to the controller.
id: 0,
name: 'Show only selected metrics/alerts',
isExpanded: true,
isSelected: false,
isVisible: true,
children: [
{
id: 1,
name: 'MetricNameA',
isExpanded: true,
isSelected: false,
isVisible: true,
children: []
},
{
id: 2,
name: 'MetricNameB',
isExpanded: true,
isSelected: false,
isVisible: true,
children: [
{
id: 3,
name: 'alertNameB',
isExpanded: true,
isSelected: true,
isVisible: true,
children: []
}
]
}
]
}],
- Use it in your template (HBS):
<!-- view tree -->
{{x-tree model=tree checkable=true}}
@ladadeedee Can you tackle this one? 😄
Examples were added here: https://github.com/btecu/ember-simple-tree/blob/master/ember-simple-tree/README.md