---
title: "jQuery Scheduler Dynamic View Switching Example | Mobiscroll"
component: "Scheduler"
framework: "jQuery"
library_version: "6.2.0"
url: "https://demo.mobiscroll.com/jquery/scheduler/switching-calendar-scheduler-agenda"
---

# Dynamic View Switching - jQuery Scheduler demo

Switch between year, month, week, day, and agenda views in the jQuery event calendar — via header control or programmatically.

- [Live demo](https://demo.mobiscroll.com/jquery/scheduler/switching-calendar-scheduler-agenda)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-jquery/tree/main/src/demos/eventcalendar/scheduler/switching-calendar-scheduler-agenda)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/scheduler/switching-calendar-scheduler-agenda.md), [Angular](https://demo.mobiscroll.com/angular/scheduler/switching-calendar-scheduler-agenda.md), [React](https://demo.mobiscroll.com/react/scheduler/switching-calendar-scheduler-agenda.md), [Vue](https://demo.mobiscroll.com/vue/scheduler/switching-calendar-scheduler-agenda.md)

## Description

Dynamically switch views within one instance. Use a UI control to let users do the switching or do it programmatically.

The example features a month view with events as labels, a weekly schedule view, a daily schedule and a weekly agenda. Use the [`setOptions`](https://mobiscroll.com/docs/jquery/eventcalendar/api#method-setOptions) method to dynamically change the settings.

## What this demo shows

- A desktop event calendar with a header segmented control for switching between year, month, week, day, and agenda views.
- **Header and segmented control** A segemnted control with `Year`, `Month`, `Week`, `Day` and `Agenda` options is positioned in the center of the header, between the year navigation label (quick navigation picker) on the left and the blue prev/next arrows with a `Today` button on the right.
- **Month view** The demo opens with the `Month` option selected and displays a desktop month view with event labels.
- **Event labels** Days with events show labels directly inside the month cells, with different colors and styles for all-day, multi-day, and timed events.
- **Overflow handling** When a day cell cannot show all events, additional events are collapsed into an `X more` label. Clicking the label opens a popover with the remaining events for that day.
- **Label interaction** Hovering or clicking an event label selects it and highlights the selected label.
- **Day cell states** Hovering an empty day cell highlights the day number with a gray background. Clicking the empty part of a cell selects the day and highlights the day number with a blue background.
- **Year view** Selecting `Year` shows all twelve months of the current year in a single scrollable layout.
- **Year view events** Days with events show a small label below the date. When multiple events are scheduled, an `X more` label opens a popover above the day cell with the events for that date.
- **Week view** Selecting `Week` shows a desktop weekly scheduler layout with a fixed week strip, a fixed all-day row, and a scrollable time grid for the selected week.
- **Week strip** The strip below the header shows the days of the selected week, with the current date highlighted by a blue circle.
- **Week events** Timed events appear in the scheduler grid as colored cards with a left color stripe, bold event title, and exact start and end time above the title.
- **Current time** A blue current-time line appears across the week time grid, with a small blue dot marking the current date.
- **Time indicator** Hovering over the week time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Day view** Selecting `Day` shows a desktop daily scheduler layout with a fixed week strip, a fixed all-day row, and a scrollable time grid for the selected day.
- **Day navigation** The week strip shows surrounding dates for quick day switching. Dates highlight on hover, and the selected day is marked with a blue circle.
- **Day events** Timed events appear in the daily scheduler grid as colored cards with a left color stripe, bold event title, and exact start and end time above the title.
- **Day current time** A blue current-time line appears across the daily time grid.
- **Day time indicator** Hovering over the daily time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Agenda view** Selecting `Agenda` shows a week calendar at the top and a daily agenda list below it.
- **Agenda selection** The agenda list displays events for the selected date. Selecting a different date in the week calendar updates the agenda automatically.
- **Agenda event markers** Days with events display a small marker below the day in the week calendar.
- **Event creation** Double-clicking or clicking and dragging in the event calendar or scheduler creates a new event.

## Best for

- **Multi-level schedule browsing** Apps where users need to move between year, month, week, day, and agenda views without leaving the same calendar instance.
- **Operational planning** Workflows that need both a broad overview of upcoming activity and detailed time-grid planning for a selected week or day.
- **Daily event review** Interfaces where users need to select a date and review that day's events in an agenda list.
- **Dense calendars** Schedules where month and year views need to handle days with more events than can fit visibly in the cell.
- **Interactive scheduling** Use cases where users create events directly from the calendar or scheduler grid.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-themeVariant) - option
- [`clickToCreate`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-clickToCreate) - option
- [`dragToCreate`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-dragToCreate) - option
- [`dragToMove`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-dragToMove) - option
- [`dragToResize`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-dragToResize) - option
- [`eventDelete`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-eventDelete) - option
- [`view`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-view) - option
- [`labels`](https://mobiscroll.com/docs/jquery/eventcalendar/api#opt-labels) - option
- [`renderHeader`](https://mobiscroll.com/docs/jquery/eventcalendar/api#renderer-renderHeader) - renderer
- [`setEvents`](https://mobiscroll.com/docs/jquery/eventcalendar/api#method-setEvents) - method
- [`setOptions`](https://mobiscroll.com/docs/jquery/eventcalendar/api#method-setOptions) - method

## Code

### JS

```js
mobiscroll.setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

$(function () {
  var calendar = $('#demo-day-week-view')
    .mobiscroll()
    .eventcalendar({
      clickToCreate: true,
      dragToCreate: true,
      dragToMove: true,
      dragToResize: true,
      eventDelete: true,
      view: {
        calendar: {
          labels: true,
        },
      },
      renderHeader: function () {
        return (
          '<div mbsc-calendar-nav class="cal-header-nav"></div>' +
          '<div class="cal-header-picker">' +
          '<label>Year<input mbsc-segmented type="radio" name="view" value="year" class="md-view-change"></label>' +
          '<label>Month<input mbsc-segmented type="radio" name="view" value="month" class="md-view-change" checked></label>' +
          '<label>Week<input mbsc-segmented type="radio" name="view" value="week" class="md-view-change"></label>' +
          '<label>Day<input mbsc-segmented type="radio" name="view" value="day" class="md-view-change"></label>' +
          '<label>Agenda<input mbsc-segmented type="radio" name="view" value="agenda" class="md-view-change"></label>' +
          '</div>' +
          '<div mbsc-calendar-prev class="cal-header-prev"></div>' +
          '<div mbsc-calendar-today class="cal-header-today"></div>' +
          '<div mbsc-calendar-next class="cal-header-next"></div>'
        );
      },
    })
    .mobiscroll('getInst');

  $.getJSON(
    'https://trial.mobiscroll.com/events/?vers=5&callback=?',
    function (events) {
      calendar.setEvents(events);
    },
    'jsonp',
  );

  $('.md-view-change').change(function (ev) {
    switch (ev.target.value) {
      case 'year':
        calendar.setOptions({
          view: {
            calendar: { type: 'year', labels: true },
          },
        });
        break;
      case 'month':
        calendar.setOptions({
          view: {
            calendar: { type: 'month', labels: true },
          },
        });
        break;
      case 'week':
        calendar.setOptions({
          view: {
            scheduler: { type: 'week' },
          },
        });
        break;
      case 'day':
        calendar.setOptions({
          view: {
            scheduler: { type: 'day' },
          },
        });
        break;
      case 'agenda':
        calendar.setOptions({
          view: {
            calendar: { type: 'week' },
            agenda: { type: 'week' },
          },
        });
        break;
    }
  });
});
```

### HTML

```html
<div id="demo-day-week-view" class="md-switching-view-cont"></div>
```

### CSS

```css
.md-switching-view-cont .mbsc-segmented {
    max-width: 350px;
    margin: 0 auto;
}

.md-switching-view-cont .mbsc-calendar-grid-item {
    height: 490px;
    box-sizing: border-box;
}

.cal-header-picker {
    flex: 1 0 auto;
}

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

/* material header order */

.mbsc-material.cal-header-prev {
    order: 1;
}

.mbsc-material.cal-header-next {
    order: 2;
}

.mbsc-material.cal-header-nav {
    order: 3;
}

.mbsc-material .cal-header-picker {
    order: 4;
}

.mbsc-material .cal-header-today {
    order: 5;
}

/* windows header order */

.mbsc-windows.cal-header-nav {
    order: 1;
}

.mbsc-windows.cal-header-prev {
    order: 2;
}

.mbsc-windows.cal-header-next {
    order: 3;
}

.mbsc-windows .cal-header-picker {
    order: 4;
}

.mbsc-windows .cal-header-today {
    order: 5;
}
```

## Implementation notes

- Define five view configurations to switch between:
  - **Year**: `{ calendar: { type: 'year' } }`
  - **Month**: `{ calendar: { labels: true } }` (initial view)
  - **Week**: `{ scheduler: { type: 'week' } }`
  - **Day**: `{ scheduler: { type: 'day' } }`
  - **Agenda**: `{ calendar: { type: 'week' }, agenda: { type: 'week' } }`
- Use `renderHeader` (Angular: `headerTemplate`, Vue: `#header` slot) to render a `SegmentedGroup` in the custom header with one option per view. On selection, update the active view; for the imperative API, call `inst.setOptions({ view: newViewConfig })`.
- Load events from `https://trial.mobiscroll.com/events/?vers=5` via JSONP using `getJson(url, callback, 'jsonp')`. For the imperative API, call `inst.setEvents(events)` in the callback.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-jquery.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config jquery
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config jquery --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/jquery/getting-started/installation

## Related demos

- Previous: [Color-Coded Time Blocks](https://demo.mobiscroll.com/jquery/scheduler/colored-cell-background.md) - Color jQuery Scheduler cell backgrounds for time ranges — mark lunch breaks, maintenance windows, or recurring schedules.
- Next: [Visible hours and days](https://demo.mobiscroll.com/jquery/scheduler/show-hide-hours-days.md) - Keep your calendar focused. Trim your view. In jQuery, you can show only weekdays and business hours, making schedules cleaner and faster.
