added a method for clearing the filter input
parent
6832ef8e31
commit
305486dc8a
|
@ -190,6 +190,10 @@ export default {
|
||||||
selectAll: {
|
selectAll: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
clearFilterOnHide: {
|
||||||
|
type: Boolean,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -285,6 +289,9 @@ export default {
|
||||||
hide() {
|
hide() {
|
||||||
this.$emit('before-hide');
|
this.$emit('before-hide');
|
||||||
this.overlayVisible = false;
|
this.overlayVisible = false;
|
||||||
|
if (this.clearFilterOnHide) {
|
||||||
|
this.filterValue = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onFocus() {
|
onFocus() {
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
|
@ -598,6 +605,9 @@ export default {
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
target: this.$el
|
target: this.$el
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
clearFilter() {
|
||||||
|
this.filterValue = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
</MultiSelect>
|
</MultiSelect>
|
||||||
|
|
||||||
<h5>Advanced with Templating and Filtering</h5>
|
<h5>Advanced with Templating and Filtering</h5>
|
||||||
<MultiSelect v-model="selectedCountries" :options="countries" optionLabel="name" placeholder="Select Countries" :filter="true" class="multiselect-custom">
|
<MultiSelect ref="advancedMultiselect" v-model="selectedCountries" :options="countries" optionLabel="name" placeholder="Select Countries" :filter="true" :clearFilterOnHide="false" class="multiselect-custom">
|
||||||
<template #value="slotProps">
|
<template #value="slotProps">
|
||||||
<div class="country-item country-item-value" v-for="option of slotProps.value" :key="option.code">
|
<div class="country-item country-item-value" v-for="option of slotProps.value" :key="option.code">
|
||||||
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + option.code.toLowerCase()" />
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + option.code.toLowerCase()" />
|
||||||
|
@ -41,6 +41,11 @@
|
||||||
<div class="country-item">
|
<div class="country-item">
|
||||||
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.option.code.toLowerCase()" />
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.option.code.toLowerCase()" />
|
||||||
<div>{{slotProps.option.name}}</div>
|
<div>{{slotProps.option.name}}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #footer="">
|
||||||
|
<div class="py-2">
|
||||||
|
<Button label="Clear filter" @click="clearAdvancedTemplatingFilterInput" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MultiSelect>
|
</MultiSelect>
|
||||||
|
@ -69,6 +74,7 @@ export default {
|
||||||
selectedGroupedCities: null,
|
selectedGroupedCities: null,
|
||||||
selectedItems: null,
|
selectedItems: null,
|
||||||
selectAll: false,
|
selectAll: false,
|
||||||
|
// clearFilterOnHide: false,
|
||||||
cities: [
|
cities: [
|
||||||
{name: 'New York', code: 'NY'},
|
{name: 'New York', code: 'NY'},
|
||||||
{name: 'Rome', code: 'RM'},
|
{name: 'Rome', code: 'RM'},
|
||||||
|
@ -125,6 +131,9 @@ export default {
|
||||||
},
|
},
|
||||||
onChange(event) {
|
onChange(event) {
|
||||||
this.selectAll = event.value.length === this.items.length
|
this.selectAll = event.value.length === this.items.length
|
||||||
|
},
|
||||||
|
clearAdvancedTemplatingFilterInput() {
|
||||||
|
this.$refs.advancedMultiselect.clearFilter()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in New Issue