Vue Agenda Event Search
Get started with this exampleUsage
theme: 'ios' You can turn auto theming on and let it decide based on the platform.
Usage
themeVariant: 'light' You can turn auto dark mode on based on system settings.
Usage
locale: localeEn Selecting the locale loads the localized settings and the translated UI text.
Event Search
Use the available real estate in the calendar header to add event search. With the templating capabilities of the header you can easily add a search box and use a separate agenda instance to show the search results. This example is relying on a single API endpoint for getting the data onto the primary view and also for getting the filtered data based on the search terms.
Events can be filtered in real time so using an agenda view for the search results is an easy choice. It provides all the necessary styling and advanced features that you might need to customize the experience.
Alternatively, search can be implemented in a sidebar next to the event calendar using a similar search box with an inline agenda instead of a dropdown.
Demo

Code
View code on GitHub
<script setup>
import {
formatDate,
getJson,
MbscCalendarNav,
MbscCalendarNext,
MbscCalendarPrev,
MbscCalendarToday,
MbscEventcalendar,
MbscInput,
MbscPopup,
setOptions
} from '@mobiscroll/vue'
import { ref } from 'vue'
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
})
const calEvents = ref([])
const isPopupOpen = ref(false)
const listEvents = ref([])
const searchInput = ref()
const selectedEvent = ref([])
const calInst = ref()
const timer = ref()
const inputRef = ref()
const calView = { agenda: { type: 'month' } }
const listView = { agenda: { type: 'year', size: 5 } }
function handleInputChange(ev) {
const searchText = ev.target.value
clearTimeout(timer.value)
timer.value = setTimeout(() => {
if (searchText.length > 0) {
getJson(
'https://trial.mobiscroll.com/searchevents/?text=' + searchText,
(data) => {
listEvents.value = data
isPopupOpen.value = true
},
'jsonp'
)
} else {
isPopupOpen.value = false
}
}, 200)
}
function handleInputFocus(ev) {
if (ev.target.value.length > 0) {
isPopupOpen.value = true
}
}
function handlePageLoading(args) {
const start = formatDate('YYYY-MM-DD', args.viewStart)
const end = formatDate('YYYY-MM-DD', args.viewEnd)
setTimeout(() => {
getJson(
'https://trial.mobiscroll.com/searchevents/?start=' + start + '&end=' + end,
(data) => {
calEvents.value = data
},
'jsonp'
)
})
}
function handleEventClick(args) {
selectedEvent.value = [args.event]
isPopupOpen.value = false
calInst.value.instance.navigateToEvent(args.event)
}
function handleInit() {
setTimeout(() => {
searchInput.value = inputRef.value.instance.nativeElement
})
}
</script>
<template>
<MbscEventcalendar
ref="calInst"
:data="calEvents"
:selectedEvents="selectedEvent"
:selectMultipleEvents="true"
:view="calView"
@init="handleInit"
@page-loading="handlePageLoading"
>
<template #header>
<MbscCalendarNav />
<div class="mds-search-bar mbsc-flex-1-0">
<MbscInput
autocomplete="off"
inputStyle="box"
placeholder="Search events"
startIcon="material-search"
ref="inputRef"
@input="handleInputChange"
@focus="handleInputFocus"
/>
</div>
<MbscCalendarPrev />
<MbscCalendarToday />
<MbscCalendarNext />
</template>
</MbscEventcalendar>
<MbscPopup
display="anchored"
:anchor="searchInput"
:contentPadding="false"
:focusElm="searchInput"
:focusOnClose="false"
:focusOnOpen="false"
:isOpen="isPopupOpen"
:scrollLock="false"
:showArrow="false"
:showOverlay="false"
:width="400"
@close="isPopupOpen = false"
>
<MbscEventcalendar
cssClass="mds-search-results"
:data="listEvents"
:showControls="false"
:view="listView"
@event-click="handleEventClick"
/>
</MbscPopup>
</template>
<style>
.mds-search-bar .mbsc-textfield-wrapper {
max-width: 400px;
margin: 8px auto;
}
.mds-search-bar .mbsc-textfield.mbsc-ios-dark {
background: #313131;
}
.mds-search-results .mbsc-calendar-wrapper {
margin-top: -1px;
}
</style> <script setup lang="ts">
import {
formatDate,
getJson,
MbscCalendarNav,
MbscCalendarNext,
MbscCalendarPrev,
MbscCalendarToday,
MbscEventcalendar,
MbscInput,
MbscPopup,
setOptions
} from '@mobiscroll/vue'
import type {
MbscCalendarEvent,
MbscEventcalendarView,
MbscEventClickEvent,
MbscPageLoadingEvent
} from '@mobiscroll/vue'
import { ref } from 'vue'
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
})
const calEvents = ref<MbscCalendarEvent[]>([])
const isPopupOpen = ref<boolean>(false)
const listEvents = ref<MbscCalendarEvent[]>([])
const searchInput = ref<HTMLInputElement>()
const selectedEvent = ref<MbscCalendarEvent[]>([])
const calInst = ref<typeof MbscEventcalendar>()
const timer = ref<ReturnType<typeof setTimeout>>()
const inputRef = ref<typeof MbscInput>()
const calView: MbscEventcalendarView = { agenda: { type: 'month' } }
const listView: MbscEventcalendarView = { agenda: { type: 'year', size: 5 } }
function handleInputChange(ev: Event) {
const input = ev.target as HTMLInputElement
const searchText = input.value
clearTimeout(timer.value)
timer.value = setTimeout(() => {
if (searchText.length > 0) {
getJson(
'https://trial.mobiscroll.com/searchevents/?text=' + searchText,
(data: MbscCalendarEvent[]) => {
listEvents.value = data
isPopupOpen.value = true
},
'jsonp'
)
} else {
isPopupOpen.value = false
}
}, 200)
}
function handleInputFocus(ev: Event) {
const input = ev.target as HTMLInputElement
if (input.value.length > 0) {
isPopupOpen.value = true
}
}
function handlePageLoading(args: MbscPageLoadingEvent) {
const start = formatDate('YYYY-MM-DD', args.viewStart!)
const end = formatDate('YYYY-MM-DD', args.viewEnd!)
setTimeout(() => {
getJson(
'https://trial.mobiscroll.com/searchevents/?start=' + start + '&end=' + end,
(data: MbscCalendarEvent[]) => {
calEvents.value = data
},
'jsonp'
)
})
}
function handleEventClick(args: MbscEventClickEvent) {
selectedEvent.value = [args.event]
isPopupOpen.value = false
calInst.value?.instance.navigateToEvent(args.event)
}
function handleInit() {
setTimeout(() => {
searchInput.value = inputRef.value?.instance.nativeElement
})
}
</script>
<template>
<MbscEventcalendar
ref="calInst"
:data="calEvents"
:selectedEvents="selectedEvent"
:selectMultipleEvents="true"
:view="calView"
@init="handleInit"
@page-loading="handlePageLoading"
>
<template #header>
<MbscCalendarNav />
<div class="mds-search-bar mbsc-flex-1-0">
<MbscInput
autocomplete="off"
inputStyle="box"
placeholder="Search events"
startIcon="material-search"
ref="inputRef"
@input="handleInputChange"
@focus="handleInputFocus"
/>
</div>
<MbscCalendarPrev />
<MbscCalendarToday />
<MbscCalendarNext />
</template>
</MbscEventcalendar>
<MbscPopup
display="anchored"
:anchor="searchInput"
:contentPadding="false"
:focusElm="searchInput"
:focusOnClose="false"
:focusOnOpen="false"
:isOpen="isPopupOpen"
:scrollLock="false"
:showArrow="false"
:showOverlay="false"
:width="400"
@close="isPopupOpen = false"
>
<MbscEventcalendar
cssClass="mds-search-results"
:data="listEvents"
:showControls="false"
:view="listView"
@event-click="handleEventClick"
/>
</MbscPopup>
</template>
<style>
.mds-search-bar .mbsc-textfield-wrapper {
max-width: 400px;
margin: 8px auto;
}
.mds-search-bar .mbsc-textfield.mbsc-ios-dark {
background: #313131;
}
.mds-search-results .mbsc-calendar-wrapper {
margin-top: -1px;
}
</style>