- Home
- Forum
- ASP.NET MVC - EJ 2
- Trying to prevent double click on an event in the schedule
Trying to prevent double click on an event in the schedule
Hello,
As the title suggests, I'm trying to block double clicking on an event in the schedule/diary. We allow users to right click and edit already existing entries/events/sessions, and we want to limit them to that. Double clicking should do nothing, ideally.
As seen here, the scheduleDialogOpen function runs when we interact with the event. I'll post the start of that function below (the actual function is about 800 lines long), but I assume we'll need to return early from the function anyway to get this working.
I've tried adding the OnDoubleClick property to the Schedule, but that only seems to run when editing a cell that already doesn't have an event in it. Any help would be greatly appreciated.
No idea what's going on with the formatting, sorry!
@Html.EJS().Schedule("diary").FirstDayOfWeek(1).QuickInfoTemplates(qit => qit.Header("#QuickHeaderTemplate").Content("#QuickContentTemplate")).Views(view =>
{
view.Option(View.Day).Add();
view.Option(View.Week).Add();
view.Option(View.WorkWeek).Add();
view.Option(View.Month).Add();
}).AllowResizing(false).AllowDragAndDrop(false).ActionBegin("DiaryBegin").ActionComplete("DiaryComplete").AllowMultiRowSelection(false).WorkHours(new ScheduleWorkHours { Start = Model.diaryDayStart, End = Model.diaryDayEnd }).EventSettings(new ScheduleEventSettings { Template = "#DiaryTemplate" }).Created("DiaryCreated").PopupOpen("scheduleDialogOpen").StartHour(Model.diaryDayStart).EndHour(Model.diaryDayEnd).EditorTemplate("#EventEditorTemplate").Render()
function scheduleDialogOpen(args) {
const schedule = this;
if (args.type === "QuickInfo") {
args.cancel = !$(args.target).hasClass("e-appointment");
return;
}
if (diaryType !== 2 && diaryType !== 3) {
args.cancel = true;
return;
}
Hi Joel,
Thank you for reaching out!
You can disable the event double-click functionality in the Scheduler by using its EventDoubleClick event and setting args.cancel = true, as demonstrated in the snippet below.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule") .Width("100%") .Height("550px") .Views(view => { view.Option(View.Week).Add(); view.Option(View.TimelineMonth).Add(); view.Option(View.Agenda).Add(); }) .EventSettings(e => e.DataSource(ViewBag.datasource)) .SelectedDate(new DateTime(2023, 4, 1)) .EventDoubleClick("onEventDoubleClick") .Render() )
<script type="text/javascript"> function onEventDoubleClick(args) { args.cancel = true; } </script> |
Sample: Attached as a zip file.
Regards,
Swathi
Attachment: mvcschedulerdisableeventdoubleclick_7ebbb584.zip
Thanks for the response!
I must have missed this property in the docs, but unfortunately it's still not working for me- should it work even when we don't use the asp.net core mvc pattern? Will post what I've added below, but the onEventDoubleClick function is just not being called when I double click events in the schedule. As you can see, the function is directly above the dialog function (which does work). Hopefully I'm missing something stupid, I'm not particularly knowledgeable about the syncfusion library as of yet!
@Html.EJS().Schedule("diary").FirstDayOfWeek(1).QuickInfoTemplates(qit => qit.Header("#QuickHeaderTemplate").Content("#QuickContentTemplate")).Views(view =>
{
view.Option(View.Day).Add();
view.Option(View.Week).Add();
view.Option(View.WorkWeek).Add();
view.Option(View.Month).Add();
}).AllowResizing(false).AllowDragAndDrop(false).ActionBegin("DiaryBegin").ActionComplete("DiaryComplete").AllowMultiRowSelection(false).WorkHours(new ScheduleWorkHours { Start = Model.diaryDayStart, End = Model.diaryDayEnd }).EventSettings(new ScheduleEventSettings { Template = "#DiaryTemplate" }).Created("DiaryCreated").PopupOpen("scheduleDialogOpen").StartHour(Model.diaryDayStart).EndHour(Model.diaryDayEnd).EditorTemplate("#EventEditorTemplate").EventDoubleClick("onEventDoubleClick").Render()
function onEventDoubleClick(args) {
args.cancel = true;
}
function scheduleDialogOpen(args) {
const schedule = this;
if (args.type === "QuickInfo") {
args.cancel = !$(args.target).hasClass("e-appointment");
return;
}
if (diaryType !== 2 && diaryType !== 3) {
args.cancel = true;
return;
}
...
Based on the code snippets you shared; we have prepared a sample in MVC and checked the reported issue. However, we were unable to replicate it, as the EventDoubleClick event triggered properly. We have attached a sample and video for your reference. If the issue persists, please share a replication sample with us. It would be greatly help us to proceed further.
Regards,
Swathi
Attachment: mvcscheduler_(2)_3f01c14e.zip
- 3 Replies
- 2 Participants
-
JW Joel Watkins
- Jan 14, 2025 12:27 PM UTC
- Jan 17, 2025 12:26 PM UTC