Pull down to refresh...
Release to refresh...
Refreshing...
-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Related Demos:
Your search did not match any results.
Loading...
Scheduler - Context Menu Integration
This demo shows how to create a context menu for appointments and cells using the onAppointmentContextMenu and onCellContextMenu functions.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
x
@model DevExtreme.MVC.Demos.ViewModels.RecurringAppointmentsViewModel
@using DevExtreme.MVC.Demos.Models;
@{
var cellContextMenuItems = new[] {
new ContextMenuItem { Text = "New Appointment", OnItemClick = new JS("createAppointment") },
new ContextMenuItem { Text = "New Recurring Appointment", OnItemClick = new JS("createRecurringAppointment") },
new ContextMenuItem { Text = "Group by Room/Ungroup", BeginGroup = true, OnItemClick = new JS("groupCell") },
new ContextMenuItem { Text = "Go to Today", OnItemClick = new JS("showCurrentDate") }
};
var resourcesData = Model.Resources.Select(r => new
{
Id = r.Id,
Text = r.Text,
Color = r.Color,
});
var appointmentContextMenuItems = new[] {
new ContextMenuItem { Text = "Open", OnItemClick = new JS("showAppointment") },
new ContextMenuItem { Text = "Delete", OnItemClick = new JS("deleteAppointment") },
new ContextMenuItem { Text = "Repeat Weekly", BeginGroup = true, OnItemClick = new JS("repeatAppointmentWeekly") },
new ContextMenuItem { Text = "Set Room", BeginGroup = true, Disabled = true }
}.Concat(
resourcesData.Select(r => new ContextMenuItem
{
Id = r.Id,
Text = r.Text,
Color = r.Color,
OnItemClick = new JS("setResource")
})
);
}
@(Html.DevExtreme().Scheduler()
.ID("scheduler")
.DataSource(Model.Appointments)
.TimeZone("America/Los_Angeles")
.Views(new[] { SchedulerViewType.Day, SchedulerViewType.Month })
.CurrentView(SchedulerViewType.Month)
.CurrentDate(new DateTime(2020, 11, 25))
.RecurrenceEditMode(SchedulerRecurrenceEditMode.Series)
.StartDayHour(9)
.Resources(res => { res.Add()
.FieldExpr("RoomId")
.ValueExpr("Id")
.ColorExpr("Color")
.DisplayExpr("Text")
.Label("Room")
.DataSource(resourcesData);
})
.OnCellContextMenu("onCellContextMenu")
.OnAppointmentContextMenu("onAppointmentContextMenu")
.Height(730)
.TextExpr("Text")
.StartDateExpr("StartDate")
.EndDateExpr("EndDate")
.RecurrenceRuleExpr("RecurrenceRule")
.RecurrenceExceptionExpr("RecurrenceException")
)
@(Html.DevExtreme().ContextMenu()
.ID("context-menu")
.Target(".dx-scheduler-appointment")
.Disabled(true)
.Width(200)
.ItemTemplate(new JS("contextMenuItemTemplate"))
)
<script>
var appointmentClassName = ".dx-scheduler-appointment";
var cellClassName = ".dx-scheduler-date-table-cell";
function onAppointmentContextMenu(e) {
var contextMenuInstance = $("#context-menu").dxContextMenu("instance");
contextMenuInstance.option({
dataSource: @Html.Raw(System.Text.Json.JsonSerializer.Serialize(appointmentContextMenuItems)),
target: appointmentClassName,
onItemClick: onItemClick(e),
disabled: false,
});
}
function onCellContextMenu(e) {
var contextMenuInstance = $("#context-menu").dxContextMenu("instance");
contextMenuInstance.option({
dataSource: @Html.Raw(System.Text.Json.JsonSerializer.Serialize(cellContextMenuItems)),
target: cellClassName,
onItemClick: onItemClick(e),
disabled: false,
});
}
function onItemClick(contextMenuEvent) {
return function (e) {
e.itemData.onItemClick(contextMenuEvent, e);
}
}
function createAppointment(e) {
e.component.showAppointmentPopup({
StartDate: e.cellData.startDate
}, true);
};
function createRecurringAppointment(e) {
e.component.showAppointmentPopup({
StartDate: e.cellData.startDate,
RecurrenceRule: "FREQ=DAILY"
}, true);
};
function groupCell(e) {
var scheduler = e.component;
if(scheduler.option("groups")) {
scheduler.option({ crossScrollingEnabled: false, groups: undefined });
} else {
scheduler.option({ crossScrollingEnabled: true, groups: ["RoomId"] });
}
};
function showCurrentDate(e) {
e.component.option("currentDate", new Date());
};
function showAppointment(e) {
e.component.showAppointmentPopup(e.appointmentData);
};
function deleteAppointment(e) {
e.component.deleteAppointment(e.appointmentData);
};
function repeatAppointmentWeekly(e) {
var itemData = e.appointmentData;
e.component.updateAppointment(itemData, $.extend(itemData, {
StartDate: e.targetedAppointmentData.StartDate,
RecurrenceRule: "FREQ=WEEKLY"
}));
};
function setResource(e, clickEvent) {
var itemData = e.appointmentData;
e.component.updateAppointment(itemData, $.extend(itemData, {
RoomId: [clickEvent.itemData.Id]
}));
};
function contextMenuItemTemplate(itemData) {
var $template = $('<div></div>');
if(itemData.Color) {
$template.append("<div class='appointment-badge' style='background-color:" + itemData.Color + ";'></div>");
}
$template.append(itemData.Text);
return $template;
}
</script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx