ember-simple-tree icon indicating copy to clipboard operation
ember-simple-tree copied to clipboard

can you provide some demo codes

Open carroll0911 opened this issue 9 years ago • 5 comments

I use ember-simple-tree in my project,but it not works,so I hope you can provide some demo codes

carroll0911 avatar Oct 31 '16 08:10 carroll0911

+1 for some demo code. I also tried something simple and it didn't work.

BryanHunt avatar Nov 11 '17 01:11 BryanHunt

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.

pdzugas avatar Nov 16 '17 10:11 pdzugas

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?

Aarondorn2 avatar Apr 04 '18 17:04 Aarondorn2

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.

  1. In your controller define the tree value. 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: []
        }
      ]
    }
  ]
}],
  1. Use it in your template (HBS):
<!-- view tree -->
      {{x-tree model=tree checkable=true}}

aaronucsd avatar Jul 12 '18 17:07 aaronucsd

@ladadeedee Can you tackle this one? 😄

btecu avatar Oct 03 '18 18:10 btecu

Examples were added here: https://github.com/btecu/ember-simple-tree/blob/master/ember-simple-tree/README.md

btecu avatar Apr 02 '25 14:04 btecu