Your search did not match any results.
Scheduler

Context Menu Integration

Documentation

This demo shows how to create a context menu for appointments and cells using the onAppointmentContextMenu and onCellContextMenu functions.

Apply
Reset
<template> <div> <dx-scheduler :data-source="dataSource" :views="views" :current-date="currentDate" :start-day-hour="9" :first-day-of-week="1" :height="600" :on-appointment-context-menu="onAppointmentContextMenu" :on-cell-context-menu="onCellContextMenu" current-view="month" recurrence-edit-mode="series" > <dx-resource :data-source="resourcesData" field-expr="roomId" label="Room" /> </dx-scheduler> <dx-context-menu :data-source="appointmentContextMenuItems" :width="200" :target="'.dx-scheduler-appointment'" :on-item-click="onAppointmentContextMenuItemClick" item-template="itemTemplateSlot" > <template #itemTemplateSlot="{ data: itemData }"> <item-template :item-data="itemData"/> </template> </dx-context-menu> <dx-context-menu :data-source="cellContextMenuItems" :target="'.dx-scheduler-date-table-cell'" :on-item-click="onCellContextMenuItemClick" /> </div> </template> <script> import DxScheduler, { DxResource } from 'devextreme-vue/scheduler'; import DxContextMenu from 'devextreme-vue/context-menu'; import ItemTemplate from './ItemTemplate.vue'; import { resourcesData, data } from './data.js'; import { cellContextMenuItems, appointmentContextMenuItems, setResource } from './MenuItems.js'; export default { components: { DxScheduler, DxResource, DxContextMenu, ItemTemplate }, data() { return { views: ['day', 'month'], currentDate: new Date(2017, 4, 25), dataSource: data, resourcesData: resourcesData, appointmentContextMenuEvent: null, cellContextMenuEvent: null, cellContextMenuItems: cellContextMenuItems, appointmentContextMenuItems: this.getAllAppointmentContextMenuItems(), }; }, methods: { onAppointmentContextMenu(e) { this.appointmentContextMenuEvent = e; }, onCellContextMenu(e) { this.cellContextMenuEvent = e; }, onAppointmentContextMenuItemClick(e) { if (!e.itemData.items && e.itemData.onItemClick) { e.itemData.onItemClick(this.appointmentContextMenuEvent, e); } }, onCellContextMenuItemClick(e) { e.itemData.onItemClick(this.cellContextMenuEvent); }, getAllAppointmentContextMenuItems() { resourcesData.map((item) => { item.onItemClick = setResource; }); return appointmentContextMenuItems.concat(resourcesData); } }, }; </script> <style scoped> .dx-menu-item-content span { margin-right: 5px; } .dx-menu-item-has-submenu .dx-icon-spinright { position: absolute; top: 7px; right: 2px; } </style>
<template> <div> <div :v-if="itemData.color" :style="styleObject" class="item-badge" /> {{ itemData.text }} <hr v-if="itemData.text === 'New Appointment until the end of the week'"> </div> </template> <script> export default { props: { itemData: { type: Object, default: () => { } }, }, data() { return { styleObject: { backgroundColor: this.itemData.color } }; } }; </script> <style scoped> .item-badge { text-align: center; float: left; margin-right: 12px; color: white; width: 18px; height: 18px; font-size: 19.5px; border-radius: 18px; margin-top: 2px; } </style>
import Vue from 'vue'; import App from './App.vue'; new Vue({ el: '#app', components: { App }, template: '<App/>' });
<!DOCTYPE html> <html> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.3/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> <span v-if="false">Loading...</span> </div> </div> </body> </html>
export const data = [ { text: 'Watercolor Landscape', roomId: [1], startDate: new Date(2017, 4, 1, 9, 30), endDate: new Date(2017, 4, 1, 11), recurrenceRule: 'FREQ=WEEKLY;BYDAY=TU,FR;COUNT=10' }, { text: 'Oil Painting for Beginners', roomId: [2], startDate: new Date(2017, 4, 1, 9, 30), endDate: new Date(2017, 4, 1, 11), recurrenceRule: 'FREQ=WEEKLY;BYDAY=MO,TH;COUNT=10' }, { text: 'Testing', roomId: [3], startDate: new Date(2017, 4, 1, 12, 0), endDate: new Date(2017, 4, 1, 13, 0), recurrenceRule: 'FREQ=WEEKLY;BYDAY=MO;WKST=TU;INTERVAL=2;COUNT=2' }, { text: 'Meeting of Instructors', roomId: [4], startDate: new Date(2017, 4, 1, 9, 0), endDate: new Date(2017, 4, 1, 9, 15), recurrenceRule: 'FREQ=DAILY;BYDAY=WE;UNTIL=20170601' }, { text: 'Recruiting students', roomId: [5], startDate: new Date(2017, 4, 26, 10, 0), endDate: new Date(2017, 4, 26, 11, 0), recurrenceRule: 'FREQ=YEARLY;BYWEEKNO=23', recurrenceException: '20170611T100000' }, { text: 'Final exams', roomId: [3], startDate: new Date(2017, 4, 26, 12, 0), endDate: new Date(2017, 4, 26, 13, 35), recurrenceRule: 'FREQ=YEARLY;BYWEEKNO=24;BYDAY=TH,FR' }, { text: 'Monthly Planning', roomId: [4], startDate: new Date(2017, 4, 26, 14, 30), endDate: new Date(2017, 4, 26, 15, 45), recurrenceRule: 'FREQ=MONTHLY;BYMONTHDAY=27;COUNT=1' }, { text: 'Open Day', roomId: [5], startDate: new Date(2017, 4, 1, 9, 30), endDate: new Date(2017, 4, 1, 13), recurrenceRule: 'FREQ=YEARLY;BYYEARDAY=148' } ]; export const resourcesData = [ { text: 'Room 101', id: 1, color: '#bbd806' }, { text: 'Room 102', id: 2, color: '#f34c8a' }, { text: 'Room 103', id: 3, color: '#ae7fcc' }, { text: 'Meeting room', id: 4, color: '#ff8817' }, { text: 'Conference hall', id: 5, color: '#03bb92' } ];
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, map: { vue: 'npm:vue@2.6.3/dist/vue.esm.browser.js', 'vue-loader': 'npm:dx-systemjs-vue-browser@latest/index.js', 'devextreme': 'npm:devextreme@19.2', 'devextreme-vue': 'npm:devextreme-vue@19.2', jszip: 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.7/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'devexpress-gantt': 'npm:devexpress-gantt', 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, meta: { '*.vue': { loader: 'vue-loader' } }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });