How to implement "Select All" for vue-treeselect library?

Viewed 276

There is a multi-select feature available in the vue-treeselect library; but what I am looking at is a "Select All" option (see snippet below):

enter image description here

Is there some undocumented config or can this feature be implemented without too much hassle?

1 Answers

add this code between the treeselect tag

<treeselect>
<div class="d-flex p-1 justify-content-center" **slot="before-list"**>
<button @click="selectAll()" type="button" class="btn btn-light">Select All</button>
<button @click="deselectAll()" type="button" class="btn btn-light">Deselect All</button>
</div>
</treeselect>

and in your method add these two functions

selectAll(){
        this.ids= [];
        this.options.forEach((value, index) => {
            this.ids.push(value);
        });
},
deselectAll(){
      this.ids = null;
},
Related