E
E
Eduard Valeev2020-08-31 03:06:59
Vue.js
Eduard Valeev, 2020-08-31 03:06:59

How to make the root element permanently open in v-treeview?

There is this tree:

<v-treeview
            v-model="selection"
            :search="search"
            :active.sync="active"
            :open="otkrytie"
            dense selectable activatable hoverable            
            :items="treeitems"
            item-disabled="locked"
            color="warning"
            selection-type="independent"
            selected-color="red" />

It has only one top-level element:
_wKumtcw7vU7q4R24ODwkmrRkvI_bUDXdNn9tojndOYt0sOMbg9GyDHXbHo0zcwjuJZ-Pg9uCK4XitEL2HhpGA==?uid=0&filename=2020-08-31+03-05-22+BH+MVP++%D0%9A%D0%BE%D0%BD%D0%%DBE D1%8C+%D0%90%D0%B4%D0%BC%D0%B8%D0%BD%D0%B8%D1%81%D1%82%D1%80%D0%B0%D1%82%D0% BE%D1%80%D0%B0+-+Google+Chrome.png&disposition=inline&hash=&limit=0&content_type=image%2Fpng&tknv=v2&owner_uid=27834637&size=2048x2048

I'm not sure what I should put in the otkrytie: [] array so that the top-level element is always open?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-08-31
@Adward

data: () => ({
  opened: [],
  ...
}),
watch: {
  opened: {
    immediate: true,
    handler(val) {
      const id = this.treeitems[0].id;
      if (!val.includes(id)) {
        val.push(id);
      }
    }
  },
  ...
},

:open.sync="opened"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question