Templates in Vue MultiSelect Dropdown
02 Sep 202624 minutes to read
The MultiSelect has been provided with several options to customize each list item, group title, selected value, header, and footer elements.
To customize MultiSelect dropdown items using templates, you can check this video:
Item template
The content of each list item within the MultiSelect can be customized with the help of itemTemplate property.
In the following sample, each list item is split into two columns to display relevant data.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :itemTemplate='itemTemplate' :dataSource='employeeData'
:query='query' :fields='fields' placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let itemVue = createApp().component("itemTemplate", {
template: `<span><span class='name'></span><span class ='city'></span></span>`,
data() {
return {
data: {}
};
}
});
const employeeData = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
const query = new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6);
const fields = { text: 'FirstName', value: 'EmployeeID' };
const itemTemplate = function (e) {
return {
template: itemVue
}
}
</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";
.city {
right: 15px;
position: absolute;
}
</style><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :itemTemplate='itemTemplate' :dataSource='employeeData'
:query='query' :fields='fields' placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let itemVue = createApp().component("itemTemplate", {
template: `<span><span class='name'></span><span class ='city'></span></span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
employeeData: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
}),
query: new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6),
fields: { text: 'FirstName', value: 'EmployeeID' },
itemTemplate: function (e) {
return {
template: itemVue
}
}
}
}
}
</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";
.city {
right: 15px;
position: absolute;
}
</style>Value template
The currently selected value that is displayed by default on the MultiSelect input element can be customized using the valueTemplate property.
In the following sample, the selected value is displayed as a combined text of both FirstName and City in the MultiSelect input, which is separated by a hyphen.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' placeholder='Select an employee' sortOrder='Ascending'
:valueTemplate="valueTemplate" :itemTemplate="itemTemplate" :dataSource='dataSource' :query='query'
:fields='fields'></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
import { DataManager, Query, ODataV4Adaptor } from "@syncfusion/ej2-data";
let itemVue = createApp().component("itemTemplate", {
template: `<span><span class='name'></span><span class ='city'></span></span>`,
data() {
return {
data: {}
};
}
});
let valueVue = createApp().component("valueTemplate", {
template: `<span> - </span>`,
data() {
return {
data: {}
};
}
});
const valueTemplate = function (e) {
return {
template: valueVue
}
};
const itemTemplate = function (e) {
return {
template: itemVue
}
};
const query = new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6);
const dataSource = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
const fields = { text: 'FirstName', value: 'EmployeeID' };
</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";
.city {
right: 15px;
position: absolute;
}
</style><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' placeholder='Select an employee' sortOrder='Ascending'
:valueTemplate="valueTemplate" :itemTemplate="itemTemplate" :dataSource='dataSource' :query='query'
:fields='fields'></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
import { DataManager, Query, ODataV4Adaptor } from "@syncfusion/ej2-data";
let itemVue = createApp().component("itemTemplate", {
template: `<span><span class='name'></span><span class ='city'></span></span>`,
data() {
return {
data: {}
};
}
});
let valueVue = createApp().component("valueTemplate", {
template: `<span> - </span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
valueTemplate: function (e) {
return {
template: valueVue
}
},
itemTemplate: function (e) {
return {
template: itemVue
}
},
query: new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6),
dataSource: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
}),
fields: { text: 'FirstName', value: 'EmployeeID' }
}
}
}
</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";
.city {
right: 15px;
position: absolute;
}
</style>Group template
The group header title under which appropriate sub-items are categorized can also be customized with the help of the groupTemplate property. This template is common for both inline and floating group header templates.
In the following sample, employees are grouped according to their city.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :groupTemplate='groupTemplate' :dataSource='employeeData'
:query='query' :fields='fields' placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor, Predicate } from '@syncfusion/ej2-data';
let itemVue = createApp().component("groupTemplate", {
template: `<strong></strong>`,
data() {
return {
data: {}
};
}
});
const employeeData = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
const query = new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6).where(new Predicate('City', 'equal', 'london').or('City', 'equal', 'seattle'));
const fields = { text: 'FirstName', value: 'EmployeeID', groupBy: 'City' };
const groupTemplate = function (e) {
return {
template: itemVue
}
}
</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><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :groupTemplate='groupTemplate' :dataSource='employeeData'
:query='query' :fields='fields' placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor, Predicate } from '@syncfusion/ej2-data';
let itemVue = createApp().component("groupTemplate", {
template: `<strong></strong>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
employeeData: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
}),
query: new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6).where(new Predicate('City', 'equal', 'london').or('City', 'equal', 'seattle')),
fields: { text: 'FirstName', value: 'EmployeeID', groupBy: 'City' },
groupTemplate: function (e) {
return {
template: itemVue
}
}
}
}
}
</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>Header template
The header element is shown statically at the top of the popup list items within the MultiSelect, and any custom element can be placed as a header element using the headerTemplate property.
In the following sample, the list items and their headers are designed and displayed as two columns similar to the multiple columns of a grid.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :headerTemplate='headerTemplate'
:itemTemplate='itemTemplate' :dataSource='employeeData' :query='query' :fields='fields'
placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let headerVue = createApp().component("headerTemplate", {
template: `<span class='head'><span class='name'>Name</span><span class='city'>City</span></span>`,
data() {
return {
data: {}
};
}
});
let itemVue = createApp().component("itemTemplate", {
template: `<span class='item' ><span class='name'></span><span class='city'></span></span>`,
data() {
return {
data: {}
};
}
});
const employeeData = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
const query = new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6);
const fields = { text: 'FirstName', value: 'EmployeeID' };
const headerTemplate = function (e) {
return {
template: headerVue
}
};
const itemTemplate = function (e) {
return {
template: itemVue
}
}
</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";
.head,
.item {
display: table;
width: 100%;
margin: auto;
}
.head {
height: 40px;
font-size: 15px;
font-weight: 600;
}
.name,
.city {
display: table-cell;
vertical-align: middle;
width: 50%;
}
.head .name {
text-indent: 16px;
}
.head .city {
text-indent: 10px;
}
</style><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' sortOrder='Ascending' :headerTemplate='headerTemplate'
:itemTemplate='itemTemplate' :dataSource='employeeData' :query='query' :fields='fields'
placeholder="Select an employee"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
var headerVue = Vue.component("headerTemplate", {
template: `<span class='head'><span class='name'>Name</span><span class='city'>City</span></span>`,
data() {
return {
data: {}
};
}
});
var itemVue = Vue.component("itemTemplate", {
template: `<span class='item' ><span class='name'></span><span class='city'></span></span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiselectComponent,
},
data() {
return {
employeeData: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ODataV4Adaptor,
crossDomain: true
}),
query: new Query().from('Employees').select(['FirstName', 'City', 'EmployeeID']).take(6),
fields: { text: 'FirstName', value: 'EmployeeID' },
headerTemplate: function (e) {
return {
template: headerVue
}
},
itemTemplate: function (e) {
return {
template: itemVue
}
}
}
}
}
</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";
.head,
.item {
display: table;
width: 100%;
margin: auto;
}
.head {
height: 40px;
font-size: 15px;
font-weight: 600;
}
.name,
.city {
display: table-cell;
vertical-align: middle;
width: 50%;
}
.head .name {
text-indent: 16px;
}
.head .city {
text-indent: 10px;
}
</style>Footer template
The MultiSelect has options to show a footer element at the bottom of the list items in the popup list. Here, you can place any custom element as a footer element using the footerTemplate property.
In the following sample, the footer element displays the total number of list items present in the MultiSelect.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' :footerTemplate='footerTemplate' :open='onPopupOpen'
:select='updateDataCount' placeholder="Select a game"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
let footerVue = createApp().component("footerTemplate", {
template: `<span class='foot'></span>`,
data() {
return {
data: {}
};
}
});
const sportsData = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
const footerTemplate = function (e) {
return {
template: footerVue
}
};
const updateDataCount = function () {
var remainingDatasCount = document.querySelectorAll('.e-list-item').length - document.querySelectorAll('.e-hide-listitem').length;
if (remainingDatasCount !== 0) {
document.querySelector('.foot').innerText = "Total list item: " + (remainingDatasCount - 1);
}
};
const onPopupOpen = function (e) {
e.popup.element.querySelector('.foot').innerText = "Total list item: " + (5 - document.querySelectorAll('.e-chips-collection .e-chips').length);
};
</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";
.foot {
text-indent: 1.2em;
display: block;
font-size: 15px;
line-height: 40px;
border-top: 1px solid #e0e0e0;
}
</style><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='sportsData' :footerTemplate='footerTemplate' :open='onPopupOpen'
:select='updateDataCount' placeholder="Select a game"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
let footerVue = createApp().component("footerTemplate", {
template: `<span class='foot'></span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
var data = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
return {
sportsData: data,
footerTemplate: function (e) {
return {
template: footerVue
}
}
}
},
methods: {
updateDataCount: function () {
var remainingDatasCount = document.querySelectorAll('.e-list-item').length - document.querySelectorAll('.e-hide-listitem').length;
if (remainingDatasCount !== 0) {
document.querySelector('.foot').innerText = "Total list item: " + (remainingDatasCount - 1);
}
},
onPopupOpen: function (e) {
e.popup.element.querySelector('.foot').innerText = "Total list item: " + (5 - document.querySelectorAll('.e-chips-collection .e-chips').length);
}
}
}
</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";
.foot {
text-indent: 1.2em;
display: block;
font-size: 15px;
line-height: 40px;
border-top: 1px solid #e0e0e0;
}
</style>No records template
The MultiSelect is provided with support to custom design the popup list content when no data is found and no matches are found on search with the help of the noRecordsTemplate property.
In the following sample, the popup list content displays a notification that no data is available.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='data' :noRecordsTemplate='noRecordsTemplate'
placeholder="Select an item"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
let footerVue = createApp().component("footerTemplate", {
template: `<span class='norecord'> NO DATA AVAILABLE</span>`,
data() {
return {
data: {}
};
}
});
const data = [];
const noRecordsTemplate = function (e) {
return {
template: footerVue
}
}
</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><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='data' :noRecordsTemplate='noRecordsTemplate'
placeholder="Select an item"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
let footerVue = createApp().component("footerTemplate", {
template: `<span class='norecord'> NO DATA AVAILABLE</span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
data: [],
noRecordsTemplate: function (e) {
return {
template: footerVue
}
}
}
}
}
</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>Action failure template
There is also an option to custom design the popup list content when the data fetch request fails at the remote server. This can be achieved using the actionFailureTemplate property.
In the following sample, when the data fetch request fails, the MultiSelect displays the notification.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :actionFailureTemplate='actionFailureTemplate' :dataSource='customerData'
:query='query' :fields='fields' placeholder="Select a customer"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { createApp } from "vue";
import { MultiSelectComponent as EjsMultiselect } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let footerVue = createApp().component("footerTemplate", {
template: `<span class='action-failure'> Data fetch get fails</span>`,
data() {
return {
data: {}
};
}
});
const customerData = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svcs/',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { text: 'ContactName', value: 'CustomerID' };
const actionFailureTemplate = function (e) {
return {
template: footerVue
}
}
</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><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :actionFailureTemplate='actionFailureTemplate' :dataSource='customerData'
:query='query' :fields='fields' placeholder="Select a customer"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { createApp } from "vue";
import { MultiSelectComponent } from "@syncfusion/ej2-vue-dropdowns";
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let footerVue = createApp().component("footerTemplate", {
template: `<span class='action-failure'> Data fetch get fails</span>`,
data() {
return {
data: {}
};
}
});
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
customerData: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svcs/',
adaptor: new ODataV4Adaptor,
crossDomain: true
}),
query: new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6),
fields: { text: 'ContactName', value: 'CustomerID' },
actionFailureTemplate: function (e) {
return {
template: footerVue
}
}
}
}
}
</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>Summary Tag Template
The Summary Tag Template feature displays selected items as a formatted summary text in the input field instead of listing all selections individually. This is especially useful in CheckBox mode when working with large datasets and using the SelectAll option, as it significantly improves performance.
The summaryTagCount property sets a threshold—when the number of selected items exceeds this threshold, the summaryTagTemplate displays a custom formatted text instead of individual items.
Template Placeholder Properties
The following properties are available for use in the summary template placeholders:
| Placeholder | Description |
|---|---|
${selectedCount} |
Total count of currently selected items |
${totalCount} |
Total number of items in the data source |
In the following sample, the Summary Tag Template displays the count of selected items when the threshold is exceeded.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='records' :fields='fields' mode='CheckBox'
:enableVirtualization='true' :allowFiltering='true' :showDropDownIcon='true'
:showSelectAll='true' :maximumSelectionLength='15000' :summaryTagCount='5'
:summaryTagTemplate='summaryTagTemplate' :value='value' placeholder="Select items"></ejs-multiselect>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { MultiSelectComponent as EjsMultiselect, CheckBoxSelection, VirtualScroll } from "@syncfusion/ej2-vue-dropdowns";
let records = [];
for (let i = 1; i <= 15000; i++) {
const item = {
id: 'id' + i,
text: 'Item ' + i,
};
records.push(item);
}
const value = records.map((item) => item.text);
const fields = { text: 'id', value: 'text' };
const summaryTagTemplate = '${selectedCount} items selected';
provide('multiselect', [CheckBoxSelection, VirtualScroll]);
</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><template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:250px;">
<br>
<ejs-multiselect id='multiselect' :dataSource='records' :fields='fields' mode='CheckBox'
:enableVirtualization='true' :allowFiltering='true' :showDropDownIcon='true'
:showSelectAll='true' :maximumSelectionLength='15000' :summaryTagCount='5'
:summaryTagTemplate='summaryTagTemplate' :value='value' placeholder="Select items"></ejs-multiselect>
</div>
</div>
</template>
<script>
import { MultiSelectComponent, CheckBoxSelection, VirtualScroll } from "@syncfusion/ej2-vue-dropdowns";
let records = [];
for (let i = 1; i <= 15000; i++) {
const item = {
id: 'id' + i,
text: 'Item ' + i,
};
records.push(item);
}
const value = records.map((item) => item.text);
export default {
name: "App",
components: {
"ejs-multiselect": MultiSelectComponent
},
data() {
return {
records: records,
fields: { text: 'id', value: 'text' },
summaryTagTemplate: '${selectedCount} items selected',
value: value
}
},
provide: {
multiselect: [CheckBoxSelection, VirtualScroll]
}
}
</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>Limitation: The Summary Tag Template feature only works in CheckBox mode because it has a built-in SelectAll option for bulk selection, which triggers the need for performance optimization. Other modes (Default, Box, Delimiter) don’t support SelectAll and use different display formats, making template-based formatting unnecessary.
Note: When you set a threshold value and preselected items exceed it, the summary template displays formatted text instead of individual items. If
summaryTagTemplateandsummaryTagCountare not provided, the Summary Tag Template feature is automatically enabled when records or preselected items exceed 1000, displaying a default summary format for better performance.