Open Event Editor Manually in Vue Schedule Component
31 Jan 202621 minutes to read
Open Editor Window Externally
The Vue Schedule component allows manually opening the event editor for a specific time range or an existing event by using the openEditor method. To open the editor for a selected time range, pass the cell details as the first argument and Add as the second argument. To open the editor for an existing event, pass that event’s details as the first argument and Save as the second argument. In the following example, clicking the corresponding button opens the respective editor window manually.
<template>
<div>
<div id='app'>
<div id='container'>
<tr>
<td>
<div>
<ejs-button v-on:click='onSubmit'>Click to open Editor</ejs-button>
</div>
</td>
<td>
<div>
<ejs-button v-on:click='onEventSubmit'>Click to open Event Editor</ejs-button>
</div>
</td>
</tr>
<br><br>
<ejs-schedule ref='scheduleObj' width='100%' height='500px' :eventSettings='eventSettings'
:selectedDate='selectedDate'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='WorkWeek'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { extend } from '@syncfusion/ej2-base';
import { scheduleData } from './datasource.js';
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, WorkWeek, Month } from '@syncfusion/ej2-vue-schedule';
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
const scheduleObj = ref(null);
const eventSettings = { dataSource: extend([], scheduleData, null, true) };
const selectedDate = new Date(2018, 1, 15);
provide('schedule', [Day, Week, WorkWeek, Month]);
const onEventSubmit = function () {
let schedule = scheduleObj.value.ej2Instances;
let eventData = {
Id: 4,
Subject: 'Meteor Showers in 2018',
StartTime: new Date(2018, 1, 14, 13, 0),
EndTime: new Date(2018, 1, 14, 14, 30)
};
schedule.openEditor(eventData, 'Save');
};
const onSubmit = function () {
let schedule = scheduleObj.value.ej2Instances;
let cellData = {
startTime: new Date(2018, 1, 15, 10, 0),
endTime: new Date(2018, 1, 15, 11, 0),
};
schedule.openEditor(cellData, 'Add');
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-calendars/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-schedule/styles/tailwind3.css';
</style><template>
<div>
<div id='app'>
<div id='container'>
<tr>
<td>
<div>
<ejs-button v-on:click='onSubmit'>Click to open Editor</ejs-button>
</div>
</td>
<td>
<div>
<ejs-button v-on:click='onEventSubmit'>Click to open Event Editor</ejs-button>
</div>
</td>
</tr>
<br><br>
<ejs-schedule ref='scheduleObj' width='100%' height='500px' :eventSettings='eventSettings'
:selectedDate='selectedDate'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='WorkWeek'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script>
import { extend } from '@syncfusion/ej2-base';
import { scheduleData } from './datasource.js';
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, WorkWeek, Month } from '@syncfusion/ej2-vue-schedule';
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-button": ButtonComponent,
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
eventSettings: { dataSource: extend([], scheduleData, null, true) },
selectedDate: new Date(2018, 1, 15)
}
},
provide: {
schedule: [Day, Week, WorkWeek, Month]
},
methods: {
onEventSubmit: function () {
let scheduleObj = this.$refs.scheduleObj.ej2Instances;
let eventData = {
Id: 4,
Subject: 'Meteor Showers in 2018',
StartTime: new Date(2018, 1, 14, 13, 0),
EndTime: new Date(2018, 1, 14, 14, 30)
};
scheduleObj.openEditor(eventData, 'Save');
},
onSubmit: function () {
let scheduleObj = this.$refs.scheduleObj.ej2Instances;
let cellData = {
startTime: new Date(2018, 1, 15, 10, 0),
endTime: new Date(2018, 1, 15, 11, 0),
};
scheduleObj.openEditor(cellData, 'Add');
}
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-calendars/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-schedule/styles/tailwind3.css';
</style>Open Editor Window on Single Click
By default, the editor window opens when cells or appointments are double-clicked. You can enable opening the editor with a single click by calling the openEditor method inside the eventClick and cellClick , and by setting the showQuickInfoproperty to false. The following example shows how to open the editor window on a single click of cells or appointments.
<template>
<div id="app">
<div id="container">
<ejs-schedule ref='scheduleObj' width="100%" height="550px" :eventSettings='eventSettings'
:selectedDate='selectedDate' :cellClick='onCellClick' :eventClick='onEventClick'
:showQuickInfo='showQuickInfo'>
<e-views>
<e-view option="Day"></e-view>
<e-view option="Week"></e-view>
<e-view option="WorkWeek"></e-view>
<e-view option="Month"></e-view>
<e-view option="Agenda"></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, WorkWeek, Month, Agenda } from "@syncfusion/ej2-vue-schedule";
import { schedulerData } from './datasource.js';
const scheduleObj = ref(null);
const eventSettings = {
dataSource: schedulerData
}
const selectedDate = new Date(2021, 7, 15)
const showQuickInfo = false
provide('schedule', [Day, Week, WorkWeek, Month, Agenda]);
const onCellClick = function (args) {
scheduleObj.value.openEditor(args, 'Add');
}
const onEventClick = function (args) {
if (!args.event.RecurrenceRule) {
scheduleObj.value.openEditor(args.event, 'Save');
}
else {
scheduleObj.value.quickPopup.openRecurrenceAlert();
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-schedule/styles/tailwind3.css';
</style><template>
<div id="app">
<div id="container">
<ejs-schedule ref='scheduleObj' width="100%" height="550px" :eventSettings='eventSettings'
:selectedDate='selectedDate' :cellClick='onCellClick' :eventClick='onEventClick'
:showQuickInfo='showQuickInfo'>
<e-views>
<e-view option="Day"></e-view>
<e-view option="Week"></e-view>
<e-view option="WorkWeek"></e-view>
<e-view option="Month"></e-view>
<e-view option="Agenda"></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script>
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, WorkWeek, Month, Agenda } from "@syncfusion/ej2-vue-schedule";
import { schedulerData } from './datasource.js';
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
eventSettings: {
dataSource: schedulerData
},
selectedDate: new Date(2021, 7, 15),
showQuickInfo: false,
}
},
provide: {
schedule: [Day, Week, WorkWeek, Month, Agenda]
},
methods: {
onCellClick: function (args) {
this.$refs.scheduleObj.openEditor(args, 'Add');
},
onEventClick: function (args) {
if (!args.event.RecurrenceRule) {
this.$refs.scheduleObj.openEditor(args.event, 'Save');
}
else {
this.$refs.scheduleObj.quickPopup.openRecurrenceAlert();
}
}
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-vue-schedule/styles/tailwind3.css';
</style>