Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you provide some demo codes #1

Open
carroll0911 opened this issue Oct 31, 2016 · 5 comments
Open

can you provide some demo codes #1

carroll0911 opened this issue Oct 31, 2016 · 5 comments

Comments

@carroll0911
Copy link

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

@BryanHunt
Copy link

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

@pdzugas
Copy link

pdzugas commented Nov 16, 2017

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.

@Aarondorn2
Copy link

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?

@aaronucsd
Copy link

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}}

@btecu
Copy link
Owner

btecu commented Oct 3, 2018

@ladadeedee Can you tackle this one? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants