amsik / liquor-tree

Tree component based on Vue.js
MIT License
398 stars 94 forks source link

Find ROOT nodes #227

Open lon9man opened 3 years ago

lon9man commented 3 years ago

i am trying to use tree API to find root nodes. BUT i didn't get correct results

EXAMPLE DATA

[
            { text: 'Item 1' },
            { text: 'Item 2', state: { expanded: true }, children: [
                { text: 'Item 2.1' },
                { text: 'Item 2.2' },
                { text: 'Item 2.3' }
            ]},
            { text: 'Item 3', state: { selected: true } },
            { text: 'Item 4' }
]

https://jsfiddle.net/longman/dqf1wLsp/4/

WHAT i USE this.$refs.tree.find({depth: 0}) OR this.$refs.tree.find({parent: null})

WHAT i GET i get ALL nodes (7 nodes)

WHAT i EXPECT return top level of nodes (4 nodes)

QUESTIONS: it works when i use find using criteria with text prop. BUT WHY i am unable to find nodes using criteria wit depth/parent props??