2

I need to display some tree structures on an application I'm working on. The sample data would be something like this:

Category 1
       - Subcategory 1.1
                - Subcategory 1.1.1:     5 items
                - Subcategory 1.1.2:     6 items
       - Subcategory 1.2
                - Subcategory 1.2.1:     2 items
Category 2
       - Subcategory 2.1
                - Subcategory 2.2.1:     5 items
                - Subcategory 2.2.2:     6 items
                - Subcategory 2.2.3:     5 items
                - Subcategory 2.2.4:     6 items

So I need to put this on a table for which i need to alter the rowspan on the parent groups. The thing is that I have no idea how to do that with Vuejs. I tried with v-for structures on the three levels, but I'm seriously lost. Has anyone done something similar with Vue?

4
  • It's not clear how you would draw such a table. Can you make a sample table in ASCII? Using something like Monodraw or ASCIIflow? Commented Apr 26, 2016 at 10:25
  • You can check out this example: vuejs.org/examples/tree-view.html Commented Apr 27, 2016 at 15:14
  • On a table, even with nested data, I encountered problems with opening and closing of the tags and the v-for. So it might not be possible to do this with a table. Other structures might be possible (where each level uses a different tag, div, span, etc). Commented Jan 18, 2017 at 18:15
  • npmjs.com/package/vue-hierarchy Commented Jul 14, 2023 at 8:53

1 Answer 1

2

Consider using CSS Grid to build the table. You could conditionally assign CSS rules ( :class ) to progressively indent. For example .level__2 { margin-left: 24px;}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.