Vue Agenda Custom Header

You can customize how the header of the agenda looks and how the components are arranged. Besides that you can also add custom functionality, like a segmented control that lets people switch between agenda and calendar.

Use the header template for passing a custom header layout. There are predefined components - shorthands if you will - that can be used to assemble the header:

  • Navigation component - <MbscCalendarNav />. Use the .md-header-filter-controls CSS class for custom overrides.
  • Today button - <MbscCalendarToday />. Use the .md-header-filter-today CSS class for custom overrides.
  • Previous month button - <MbscCalendarPrev />. Use the .md-header-filter-prev CSS class for custom overrides.
  • Next month button - <MbscCalendarNext />. Use the .md-header-filter-next CSS class for custom overrides.

For changing the order the controls are laid out, you only need to set up the header template. This example sets a consistent order and layout across all themes and shows a custom control at the far right end.

Overriding the order for specific themes

For a custom order on a theme to theme basis, you will need to use a little CSS. Flex layout makes reordering easy. It's just a matter of setting the order in CSS. For material use the .mbsc-material, for windows the .mbsc-windows prefix and for iOS it is .mbsc-ios class. Eg.:

.mbsc-material .md-header-filter-prev { order: 1; }
            .mbsc-material .md-header-filter-next { order: 2; }
            .mbsc-material .md-header-filter-controls { order: 3; }
            .mbsc-material .md-header-filter-today { order: 4; }
Want to add a filter to the header?  Check out the next example →
Get started with this example

Demo

Loading the live demo

Preview in full screen

Build a custom header for the event calendar agenda — assemble navigation controls, add a segmented view switcher or any custom action.

Code

<script setup>
import {
  getJson,
  MbscButton,
  MbscCalendarNav,
  MbscCalendarToday,
  MbscEventcalendar,
  MbscSegmented,
  MbscSegmentedGroup,
  setOptions 
} from '@mobiscroll/vue'
import { onMounted, ref } from 'vue'

setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
})

const currentDate = ref(new Date())
const currentView = ref('agenda')
const myEvents = ref([])
const myView = ref({ agenda: { type: 'month' } })

function changeView() {
  switch (currentView.value) {
    case 'calendar':
      myView.value = {
        calendar: { type: 'month' }
      }
      break
    case 'agenda':
      myView.value = {
        agenda: { type: 'month' }
      }
      break
  }
}

function prevPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() - 1, 1)
}

function nextPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() + 1, 1)
}

onMounted(() => {
  getJson(
    'https://trial.mobiscroll.com/events/?vers=5',
    (events) => {
      myEvents.value = events
    },
    'jsonp'
  )
})
</script>

<template>
  <MbscEventcalendar :data="myEvents" :selectedDate="currentDate" :view="myView">
    <template #header>
      <MbscCalendarNav className="mds-custom-header-nav"></MbscCalendarNav>
      <div class="mbsc-flex mbsc-flex-1-0 mbsc-justify-content-center">
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-back"
          variant="flat"
          @click="prevPage()"
        />
        <MbscCalendarToday />
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-forward"
          variant="flat"
          @click="nextPage()"
        />
      </div>
      <div class="mds-custom-header-switch">
        <MbscSegmentedGroup v-model="currentView" @change="changeView()">
          <MbscSegmented value="agenda" icon="material-view-day" />
          <MbscSegmented value="calendar" icon="calendar" />
        </MbscSegmentedGroup>
      </div>
    </template>
  </MbscEventcalendar>
</template>

<style>
.mds-custom-header-nav {
  width: 180px;
}

.mds-custom-header-button.mbsc-button {
  font-size: 20px;
  height: auto;
  padding: 0;
  margin: 0;
}

.mds-custom-header-switch .mbsc-segmented {
  width: 110px;
  margin-top: 0;
  margin-bottom: 0;
}

.mds-custom-header-switch .mbsc-segmented.mbsc-material,
.mds-custom-header-switch .mbsc-segmented.mbsc-windows {
  padding: 0;
}

.mds-custom-header-switch .mbsc-segmented-button.mbsc-button {
  font-size: 20px;
  height: 32px;
  padding: 0;
}
</style>

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.