-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Action Sheet
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
JavaScript/jQuery Scheduler - Context Menu
This demo shows how to create a context menu for appointments and cells using the onAppointmentContextMenu and onCellContextMenu functions.
Backend API
$(() => {
$('#scheduler').dxScheduler({
timeZone: 'America/Los_Angeles',
dataSource: data,
views: ['day', 'month'],
currentView: 'month',
currentDate: new Date(2020, 10, 25),
startDayHour: 9,
recurrenceEditMode: 'series',
groups: [],
onAppointmentContextMenu(e) {
const items = getAppointmentContextMenuItems(e);
contextMenuInstance.option('dataSource', items);
},
onCellContextMenu(e) {
const items = getCellContextMenuItems(e);
contextMenuInstance.option('dataSource', items);
},
resources: [{
fieldExpr: 'roomId',
dataSource: resourcesData,
label: 'Room',
icon: 'conferenceroomoutline',
}],
height: 730,
});
const contextMenuInstance = $('#context-menu').dxContextMenu({
width: 200,
dataSource: [],
target: '#scheduler',
itemTemplate: contextMenuItemTemplate,
onItemClick: (e) => {
e.itemData.onItemClick(e);
},
onHiding: (e) => {
e.component.option('dataSource', []);
},
}).dxContextMenu('instance');
function contextMenuItemTemplate(itemData) {
const template = $('<div></div>');
if (itemData.color) {
$('<div>')
.addClass('item-badge')
.css('background-color', itemData.color)
.appendTo(template);
}
template.append(itemData.text);
return template;
}
function getAppointmentContextMenuItems(e) {
const scheduler = e.component;
const { appointmentData: appointment, targetedAppointmentData: targetedAppointment } = e;
return [
{
text: 'Open',
onItemClick: () => { scheduler.showAppointmentPopup(appointment); },
},
{
text: 'Delete',
onItemClick: () => { scheduler.deleteAppointment(appointment); },
},
{
text: 'Repeat Weekly',
beginGroup: true,
onItemClick: () => {
scheduler.updateAppointment(appointment, $.extend(appointment, {
startDate: targetedAppointment.startDate,
recurrenceRule: 'FREQ=WEEKLY',
}));
},
},
{
text: 'Set Room',
beginGroup: true,
disabled: true,
},
...resourcesData.map((item) => ({
...item,
onItemClick: (clickEvent) => {
scheduler.updateAppointment(appointment, $.extend(appointment, {
roomId: [clickEvent.itemData.id],
}));
},
})),
];
}
function getCellContextMenuItems(e) {
const scheduler = e.component;
return [
{
text: 'New Appointment',
onItemClick: () => {
scheduler.showAppointmentPopup({
startDate: e.cellData.startDateUTC,
}, true);
},
},
{
text: 'New Recurring Appointment',
onItemClick: () => {
scheduler.showAppointmentPopup({
startDate: e.cellData.startDateUTC,
recurrenceRule: 'FREQ=DAILY',
}, true);
},
},
{
text: 'Group by Room/Ungroup',
beginGroup: true,
onItemClick: () => {
if (scheduler.option('groups').length) {
scheduler.option({ crossScrollingEnabled: false, groups: [] });
} else {
scheduler.option({ crossScrollingEnabled: true, groups: ['roomId'] });
}
},
},
{
text: 'Go to Today',
onItemClick: () => {
scheduler.option('currentDate', new Date());
},
},
];
}
});
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<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=5.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/25.2.5/css/dx.light.css" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="js/dx.all.js?v=25.2.5"></script>
<script src="data.js"></script>
<script src="index.js"></script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="scheduler"></div>
<div id="context-menu"></div>
</div>
</body>
</html>
.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;
}
const data = [
{
text: 'Watercolor Landscape',
roomId: [1],
startDate: new Date('2020-11-01T17:30:00.000Z'),
endDate: new Date('2020-11-01T19:00:00.000Z'),
recurrenceRule: 'FREQ=WEEKLY;BYDAY=MO,TH;COUNT=10',
}, {
text: 'Oil Painting for Beginners',
roomId: [2],
startDate: new Date('2020-11-01T17:30:00.000Z'),
endDate: new Date('2020-11-01T19:00:00.000Z'),
recurrenceRule: 'FREQ=WEEKLY;BYDAY=SU,WE;COUNT=10',
}, {
text: 'Testing',
roomId: [3],
startDate: new Date('2020-11-01T20:00:00.000Z'),
endDate: new Date('2020-11-01T21:00:00.000Z'),
recurrenceRule: 'FREQ=WEEKLY;BYDAY=SU;WKST=TU;INTERVAL=2;COUNT=2',
}, {
text: 'Meeting of Instructors',
roomId: [4],
startDate: new Date('2020-11-01T17:00:00.000Z'),
endDate: new Date('2020-11-01T17:15:00.000Z'),
recurrenceRule: 'FREQ=DAILY;BYDAY=TU;UNTIL=20201203',
}, {
text: 'Recruiting students',
roomId: [5],
startDate: new Date('2020-10-24T18:00:00.000Z'),
endDate: new Date('2020-10-24T19:00:00.000Z'),
recurrenceRule: 'FREQ=YEARLY;BYWEEKNO=50;WKST=SU',
recurrenceException: '20201212T190000Z',
}, {
text: 'Final exams',
roomId: [3],
startDate: new Date('2020-10-24T20:00:00.000Z'),
endDate: new Date('2020-10-24T21:35:00.000Z'),
recurrenceRule: 'FREQ=YEARLY;BYWEEKNO=51;BYDAY=WE,TH',
}, {
text: 'Monthly Planning',
roomId: [4],
startDate: new Date('2020-11-24T22:30:00.000Z'),
endDate: new Date('2020-11-24T23:45:00.000Z'),
recurrenceRule: 'FREQ=MONTHLY;BYMONTHDAY=28;COUNT=1',
}, {
text: 'Open Day',
roomId: [5],
startDate: new Date('2020-11-01T17:30:00.000Z'),
endDate: new Date('2020-11-01T21:00:00.000Z'),
recurrenceRule: 'FREQ=YEARLY;BYYEARDAY=333',
},
];
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',
},
];