Switch Day, Week and Month Views

Dynamically switch views within one calendar instance. Use a UI control to let users do the switching or do it programmatically. This example features a segmented component inside the header, but the live option changes can be invoked from anywhere.

Switch between a month view with a monthly agenda, a week view with a weekly agenda and daily event list.

Thanks to property binding and all option changes are live and propagate accordingly.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Switch a event calendar between day, week, and month views using a header segmented control — each view paired with a matching agenda list.

Code

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

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

const myEvents = ref([])

const myView = ref({
  calendar: { type: 'month' },
  agenda: { type: 'month' }
})

const view = ref('month')

function changeView() {
  setTimeout(() => {
    switch (view.value) {
      case 'month':
        myView.value = {
          calendar: { type: 'month' },
          agenda: { type: 'month' }
        }
        break
      case 'week':
        myView.value = {
          calendar: { type: 'week' },
          agenda: { type: 'week' }
        }
        break
      case 'day':
        myView.value = {
          agenda: { type: 'day' }
        }
        break
    }
  })
}

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

<template>
  <MbscEventcalendar :clickToCreate="" :dragToCreate="" :dragToMove="" :dragToResize="" :eventDelete="" :view="myView" :data="myEvents">
    <template #header>
      <MbscCalendarNav />
      <div class="mbsc-flex mbsc-flex-1-0 mbsc-justify-content-center">
        <MbscSegmentedGroup v-model="view" @change="changeView()">
          <MbscSegmented value="month" icon="material-event-note"></MbscSegmented>
          <MbscSegmented value="week" icon="material-date-range"></MbscSegmented>
          <MbscSegmented value="day" icon="material-view-day"></MbscSegmented>
        </MbscSegmentedGroup>
      </div>
      <MbscCalendarPrev cssClass="cal-header-prev" />
      <MbscCalendarNext cssClass="cal-header-next" />
    </template>
  </MbscEventcalendar>
</template>

<style>
.md-switching-view-cont {
  height: 100%;
}

.md-switching-view-cont .mbsc-segmented {
  margin: 0;
}

.md-switching-view-cont .mbsc-segmented.mbsc-material,
.md-switching-view-cont .mbsc-segmented.mbsc-windows {
  padding: 0;
}

.md-switching-view-cont .mbsc-segmented .mbsc-segmented-button {
  padding: 0 1px;
}

.md-switching-view-cont .mbsc-segmented .mbsc-icon {
  font-size: 20px;
}

.md-switching-view-cont .mbsc-segmented-button.mbsc-windows {
  border: 0;
}

.cal-header-picker {
  -webkit-flex: 1 0 auto;
  -moz-box-flex: 1;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-justify-content: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.cal-header-nav {
  width: 165px;
}

.cal-header-nav .mbsc-calendar-title.mbsc-material {
  font-size: 16px;
}
</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.