diff --git a/src/views/multiselect/MultiSelectDemo.vue b/src/views/multiselect/MultiSelectDemo.vue index 025f7bab2..eb6f566ae 100755 --- a/src/views/multiselect/MultiSelectDemo.vue +++ b/src/views/multiselect/MultiSelectDemo.vue @@ -47,6 +47,9 @@
-<MultiSelect v-model="selectedGroupedCities" :options="groupedCities"
+<MultiSelect v-model="selectedGroupedCities" :options="groupedCities"
optionLabel="label" optionGroupLabel="label" optionGroupChildren="items">
</MultiSelect>
@@ -301,6 +301,30 @@ export default {
string
pi pi-spinner pi-spin
Icon to display in loading state.
+
+
+ maxSelectedLabels
+ number
+ null
+ Decides how many selected item labels to show at most.
+
+
+ selectedItemsLabel
+ string
+ {0} items selected
+ Label to display after exceeding max selected labels.
+
+
+ selectAll
+ boolean
+ false
+ Whether all data is selected.
+
+
+ virtualScrollerOptions
+ object
+ null
+ Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it.
@@ -349,6 +373,12 @@ export default {
event.value: Filter value
Callback to invoke on filter input.
+
+ selectall-change
+ event.originalEvent: Original event
+ event.checked: Whether all data is selected.
+ Callback to invoke when all data is selected.
+
@@ -528,6 +558,9 @@ export default {
Loading State
+
+ Virtual Scroll (1000 Items)
+
@@ -539,6 +572,8 @@ export default {
selectedCities2: null,
selectedCountries: null,
selectedGroupedCities: null,
+ selectedItems: null,
+ selectAll: false,
cities: [
{name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'},
@@ -559,7 +594,7 @@ export default {
{name: 'United States', code: 'US'}
],
groupedCities: [{
- label: 'Germany', code: 'DE',
+ label: 'Germany', code: 'DE',
items: [
{label: 'Berlin', value: 'Berlin'},
{label: 'Frankfurt', value: 'Frankfurt'},
@@ -568,7 +603,7 @@ export default {
]
},
{
- label: 'USA', code: 'US',
+ label: 'USA', code: 'US',
items: [
{label: 'Chicago', value: 'Chicago'},
{label: 'Los Angeles', value: 'Los Angeles'},
@@ -577,14 +612,24 @@ export default {
]
},
{
- label: 'Japan', code: 'JP',
+ label: 'Japan', code: 'JP',
items: [
{label: 'Kyoto', value: 'Kyoto'},
{label: 'Osaka', value: 'Osaka'},
{label: 'Tokyo', value: 'Tokyo'},
{label: 'Yokohama', value: 'Yokohama'}
]
- }]
+ }],
+ items: Array.from({ length: 1000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i }))
+ },
+ methods: {
+ onSelectAllChange(event) {
+ this.selectedItems = event.checked ? this.items.map((item) => item.value) : [];
+ this.selectAll = event.checked;
+ },
+ onChange(event) {
+ this.selectAll = event.value.length === this.items.length
+ }
}
}
}
@@ -664,6 +709,9 @@ export default {
Loading State
+
+ Virtual Scroll (1000 Items)
+
@@ -676,6 +724,8 @@ export default {
const selectedCities2 = ref();
const selectedCountries = ref();
const selectedGroupedCities = ref();
+ const selectedItems = ref();
+ const selectAll = ref(false);
const cities = ref([
{name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'},
@@ -697,7 +747,7 @@ export default {
]);
const groupedCities = ref([
{
- label: 'Germany', code: 'DE',
+ label: 'Germany', code: 'DE',
items: [
{label: 'Berlin', value: 'Berlin'},
{label: 'Frankfurt', value: 'Frankfurt'},
@@ -706,7 +756,7 @@ export default {
]
},
{
- label: 'USA', code: 'US',
+ label: 'USA', code: 'US',
items: [
{label: 'Chicago', value: 'Chicago'},
{label: 'Los Angeles', value: 'Los Angeles'},
@@ -715,7 +765,7 @@ export default {
]
},
{
- label: 'Japan', code: 'JP',
+ label: 'Japan', code: 'JP',
items: [
{label: 'Kyoto', value: 'Kyoto'},
{label: 'Osaka', value: 'Osaka'},
@@ -724,8 +774,18 @@ export default {
]
}
]);
+ const items = Array.from({ length: 1000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i }))
- return { selectedCities1, selectedCities2, selectedCountries, selectedGroupedCities, cities, countries, groupedCities }
+ return { selectedCities1, selectedCities2, selectedCountries, selectedGroupedCities, cities, countries, groupedCities, items, selectedItems, selectAll }
+ },
+ methods: {
+ onSelectAllChange(event) {
+ this.selectedItems = event.checked ? this.items.map((item) => item.value) : [];
+ this.selectAll = event.checked;
+ },
+ onChange(event) {
+ this.selectAll = event.value.length === this.items.length
+ }
}
}
<\\/script>