The MultiSelect has built-in support to select multiple values through checkbox,
when mode
property set as CheckBox
.
To use checkbox, inject the CheckBoxSelection
module in the MultiSelect.
<template>
<div id="app">
<div id='container' style="margin:15px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' placeholder="Find a game" mode="CheckBox" :fields='fields'></ejs-multiselect>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import { MultiSelectPlugin } from "@syncfusion/ej2-vue-dropdowns";
import { MultiSelect, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';
MultiSelect.Inject(CheckBoxSelection);
Vue.use(MultiSelectPlugin);
export default {
data (){
return {
sportsData: [
{ Id: 'game1', Game: 'Badminton' },
{ Id: 'game2', Game: 'Football' },
{ Id: 'game3', Game: 'Tennis' },
{ Id: 'game4', Game: 'Golf' },
{ Id: 'game5', Game: 'Cricket' },
{ Id: 'game6', Game: 'Handball' },
{ Id: 'game7', Game: 'Karate' },
{ Id: 'game8', Game: 'Fencing' },
{ Id: 'game9', Game: 'Boxing' }
],
fields : { text: 'Game', value: 'Id' }
}
}
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
</style>
The MultiSelect component has in-built support to select the all list items using Select All
options in the header.
When the showSelectAll
property is set to true, by default Select All text will show.
You can customize the name attribute of the Select All option by using
selectAllText
.
For the unSelect All option, by default unSelect All text will show.
You can customize the name attribute of the unSelect All option by using
unSelectAllText
.
<template>
<div id="app">
<div id='container' style="margin:15px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' placeholder="Select a game" mode="CheckBox" :fields='fields' :showSelectAll='showSelectAll' selectAllText="Select All" unSelectAllText="unSelect All"></ejs-multiselect>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import { MultiSelectPlugin } from "@syncfusion/ej2-vue-dropdowns";
import { MultiSelect, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';
MultiSelect.Inject(CheckBoxSelection);
Vue.use(MultiSelectPlugin);
export default {
data (){
return {
sportsData: [
{ Id: 'game1', Game: 'Badminton' },
{ Id: 'game2', Game: 'Football' },
{ Id: 'game3', Game: 'Tennis' },
{ Id: 'game4', Game: 'Golf' },
{ Id: 'game5', Game: 'Cricket' },
{ Id: 'game6', Game: 'Handball' },
{ Id: 'game7', Game: 'Karate' },
{ Id: 'game8', Game: 'Fencing' },
{ Id: 'game9', Game: 'Boxing' }
],
fields : { text: 'Game', value: 'Id' },
showSelectAll : true
}
}
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
</style>
Defines the limit of the selected items using maximumSelectionLength
.
<template>
<div id="app">
<div id='container' style="margin:15px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' placeholder="Select a game" mode="CheckBox" :fields='fields' :maximumSelectionLength='maximumSelectionLength'></ejs-multiselect>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import { MultiSelectPlugin } from "@syncfusion/ej2-vue-dropdowns";
import { MultiSelect, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';
MultiSelect.Inject(CheckBoxSelection);
Vue.use(MultiSelectPlugin);
export default {
data (){
return {
sportsData: [
{ Id: 'game1', Game: 'Badminton' },
{ Id: 'game2', Game: 'Football' },
{ Id: 'game3', Game: 'Tennis' },
{ Id: 'game4', Game: 'Golf' },
{ Id: 'game5', Game: 'Cricket' },
{ Id: 'game6', Game: 'Handball' },
{ Id: 'game7', Game: 'Karate' },
{ Id: 'game8', Game: 'Fencing' },
{ Id: 'game9', Game: 'Boxing' }
],
fields : { text: 'Game', value: 'Id' },
maximumSelectionLength : 3
}
}
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
</style>
Using enableSelectionOrder
to Reorder the selected items in popup visibility state.
<template>
<div id="app">
<div id='container' style="margin:15px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' placeholder="Select a game" mode="CheckBox" :fields='fields' :enableSelectionOrder='enableSelectionOrder'></ejs-multiselect>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import { MultiSelectPlugin } from "@syncfusion/ej2-vue-dropdowns";
import { MultiSelect, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';
MultiSelect.Inject(CheckBoxSelection);
Vue.use(MultiSelectPlugin);
export default {
data (){
return {
sportsData: [
{ Id: 'game1', Game: 'Badminton' },
{ Id: 'game2', Game: 'Football' },
{ Id: 'game3', Game: 'Tennis' },
{ Id: 'game4', Game: 'Golf' },
{ Id: 'game5', Game: 'Cricket' },
{ Id: 'game6', Game: 'Handball' },
{ Id: 'game7', Game: 'Karate' },
{ Id: 'game8', Game: 'Fencing' },
{ Id: 'game9', Game: 'Boxing' }
],
fields : { text: 'Game', value: 'Id' },
enableSelectionOrder : false
}
}
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
</style>