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

Tree data field where path is its property #54

Open
dipzera opened this issue Jun 3, 2021 · 4 comments
Open

Tree data field where path is its property #54

dipzera opened this issue Jun 3, 2021 · 4 comments

Comments

@dipzera
Copy link

dipzera commented Jun 3, 2021

May I have an example on giving the tree data let's say a sort field, where this field is tree component's path property?
Ex. { name: "Category 1", sort: [0, 1, 1, 1] }

@phphe
Copy link
Owner

phphe commented Jun 3, 2021

I'm sorry, I'm confused about what you're saying. No sort field. There is a node path variable, it is node position, can be access by scoped slot.

<span slot-scope="{node, index, path, tree}">
  <b>{{index}}</b>
  Title: {{node.title}}
  - path: <i>{{path.join(',')}}</i>
</span>

Type: Array
Detail: Node position in TreeData. Starting from the highest second level, the serial number of each level in the parent.
Example: [{text: 'node 1'}, {text: 'node 2', children: [{text: 'node 3'}]}], path of 'node 3' is [1, 0]

@dipzera
Copy link
Author

dipzera commented Jun 3, 2021

Sorry for not explaining too well, what I was trying to say is that I want my tree data elements to have a property where the value is the node position (node path variable you were talking about).

@phphe
Copy link
Owner

phphe commented Jun 3, 2021

tree only reads nested data, and exports nested data, like this:

[{text: 'node 1'}, {text: 'node 2', children: [{text: 'node 2-1'}]}]

If your data is not nested and use property to store structure, like parent_id, you need transform the data before pass into tree.

@dipzera
Copy link
Author

dipzera commented Jun 4, 2021

Ok thanks, thought would be great to be able to store/save the path variable.

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

2 participants