State Persistence in Vue Scheduler
State persistence allows the Scheduler to retain the currentView, selectedDate, and scroll position values in localStorage for state maintenance even if the browser is refreshed or you move to another page in the browser. This behavior is handled through the enablePersistence property, which is set to false by default. When it is set to true, currentView, selectedDate, and scroll position values of the Scheduler component are retained even after refreshing the page.
Note: The Scheduler
idis required to enable state persistence.
The following sample demonstrates how to enable state persistence for the Scheduler component.
<template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' width='100%' :selectedDate='selectedDate' :eventSettings='eventSettings'
:enablePersistence='enablePersistence'>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { scheduleData } from './datasource.js';
import { ScheduleComponent as EjsSchedule, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
const selectedDate = new Date(2018, 1, 15);
const views = ['Day', 'Week', 'TimelineWeek', 'Month', 'Agenda'];
const enablePersistence = true;
const eventSettings = { dataSource: scheduleData };
provide('schedule', [Day, Week, TimelineViews, Month, Agenda]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' width='100%' :selectedDate='selectedDate' :eventSettings='eventSettings'
:enablePersistence='enablePersistence'>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script>
import { scheduleData } from './datasource.js';
import { ScheduleComponent, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent
},
data() {
return {
selectedDate: new Date(2018, 1, 15),
views: ['Day', 'Week', 'TimelineWeek', 'Month', 'Agenda'],
enablePersistence: true,
eventSettings: { dataSource: scheduleData }
}
},
provide: {
schedule: [Day, Week, TimelineViews, Month, Agenda]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>For a complete overview of Scheduler features, visit the Vue Scheduler feature tour page. Explore live examples at Vue Scheduler example to learn how to present and manipulate data.