-
Notifications
You must be signed in to change notification settings - Fork 152
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
Adding Buttons in dropdown like Select All, Deselect All. #172
Comments
This should be it: <template>
<div id="app">
<div>
<Multiselect
v-model="value"
:options="options"
mode="multiple"
ref="select$"
>
<template #beforelist>
<a href="" @click.prevent="handleSelectAll">Select all</a> •
<a href="" @click.prevent="handleDeselectAll">Deselect all</a>
</template>
</Multiselect>
</div>
</div>
</template>
<script>
import Multiselect from '@vueform/multiselect'
export default {
name: 'App',
components: {
Multiselect,
},
data() {
return {
value: [],
options: ['value1', 'value2', 'value3'],
select$: null,
}
},
methods: {
handleSelectAll() {
this.select$.selectAll()
},
handleDeselectAll() {
this.select$.clear()
},
},
mounted() {
this.select$ = this.$refs.select$
}
}
</script> The handleSelectAll() {
this.select$.select(this.select$.filteredOptions)
} |
For some reason when I click many times this "Select all" button - it doubles 'internalValue', and the length of values doubles, so even the message 'multipleLabelText' increases with the count of values |
Found the solution. When click 'Select all' just execute 'Deselect all' and 'Select all' methods |
This how it's suppose to happen with composition api ? |
I tried achieving this with beforelist, but was not able to make the button reactive, i even tried putting as check boxes still nothing worked.
is there a way we can implement this? or can we get it built in as options?
The text was updated successfully, but these errors were encountered: