search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Left Click Context Menu

Asked by Stephanie
4 years ago.

I see several old questions related to this. I have a context menu for time clicking but it only works for the right click. I need a way to have it work for the left click as well.

Answer posted by Dan Letecky [DayPilot]
4 years ago.

You can open a context menu using javascript like this:

menu.show(e);

In the ASP.NET WebForms version, set EventClickHandling="JavaScript" and EventClickJavaScript="menu.show(e)".

This assumes you have defined a context menu with ClientObjectName="menu".

Comment posted by Stephanie
4 years ago.

Thanks Dan! I have tried that but the menu does not show up when I left click only right clicking still brings up the menu....

I have:
<DayPilot:DayPilotMenu runat="server" ID="dpm_Schedule" ClientObjectName="menu" />

And:
EventClickHandling="JavaScript" EventClickJavaScript="menu.show(e)" ContextMenuSelectionID="dpm_Schedule"

Comment posted by Stephanie
4 years ago.

Any other ideas?

Comment posted by Dan Letecky [DayPilot]
4 years ago.

Sorry - the example I provided works for event clicking. If you need to apply it to the grid cell clicking (= time range selecting), use TimeRangeSelectedHandling and TimeRangeSelectedJavaScript instead.

Comment posted by Stephanie
4 years ago.

Thanks for the reply. I had assumed that and tried that as well, but no menu shows on left click...still only on right click.

Comment posted by Dan Letecky [DayPilot]
4 years ago.

Stephanie,

Sorry for the delay.

I have tried adding this to the main Scheduler demo page (http://www.daypilot.org/demo/Scheduler/) and it seems to work fine:

<DayPilot:DayPilotScheduler
        TimeRangeSelectedHandling="JavaScript"
        TimeRangeSelectedJavaScript="cmSelection.show({start: start, end: end, resource:resource});"
...
/>

    <DayPilot:DayPilotMenu ID="DayPilotMenuSelection" runat="server" ClientObjectName="cmSelection">
        <DayPilot:MenuItem Action="JavaScript" JavaScript="dps1.timeRangeSelectedCallBack(e.start, e.end, e.resource);"
            Text="Create new event (JavaScript)" />
        <DayPilot:MenuItem Action="PostBack" Command="Insert" Text="Create new event (PostBack)" />
        <DayPilot:MenuItem Action="CallBack" Command="Insert" Text="Create new event (CallBack)" />
        <DayPilot:MenuItem Text="-" Action="JavaScript"></DayPilot:MenuItem>
        <DayPilot:MenuItem Action="JavaScript" JavaScript="alert('Start: ' + e.start + '\nEnd: ' + e.end + '\nResource id: ' + e.resource);"
            Text="Show selection details" />
        <DayPilot:MenuItem Action="JavaScript" JavaScript="dps1.clearSelection();" Text="Clean selection" />
    </DayPilot:DayPilotMenu>
Comment posted by Stephanie
4 years ago.

Thanks Dan, I am not sure why mine will not work then....Is it because I am building the menu items dynamically? Or because I am using the Calendar not the Scheduler?

I have the menu defined as:

<DayPilot:DayPilotMenu runat="server" ID="dpm_Schedule" ClientObjectName="menu" />

I have my calendar defined as:

<daypilot:daypilotcalendar runat="server" id="DayPilotCalendar1" BubbleID="DayPilotBubble1" Width="100%" HeightSpec="Fixed" Height="500" ContextMenuID="dpm_Event"
ShowToolTip="false" BackColor="#ffffff" NonBusinessBackColor="#eeeeee" BorderColor="#999999" HourBorderColor="#999999" HourHalfBorderColor="#cccccc" CellBorderColor="#999999" EventBorderColor="#999999"
DataEndField="End" DataStartField="Start" DataTextField="name" DataIdField="id" CellDuration="15"
RecurrentEventImage="/Secure/Skins/Media/recur10x9.png" RecurrentEventExceptionImage="/Secure/Skins/Media/recurex10x9.png"
DataTagFields="name, id, course, color, eventtypename, navurl, recstart, client" DataRecurrenceField="recurrence"
OnBeforeEventRender="DayPilotCalendar1_BeforeEventRender" OnBeforeCellRender="DayPilotCalendar1_BeforeCellRender"
EventRightClickHandling="ContextMenu" OnEventMenuClick="DayPilotCalendar1_EventMenuClick" ContextMenuSelectionID="dpm_Schedule"
EventClickHandling="ContextMenu" ShowAllDayEvents="true" DataAllDayField="allday" ShowAllDayEventStartEnd="false" AllDayEnd="Date"
ViewType="Week" Theme="dbpcalendar" Crosshair="Disabled" TimeRangeSelectedHandling="JavaScript" TimeRangeSelectedJavaScript="menu.show(e)"
/>

I get the menu on right click but not a regular left click.

Comment posted by Dan Letecky [DayPilot]
4 years ago.

I've tested it with the Calendar as well and it works fine. Just one thing: "e" is not available in the TimeRangeSelectedJavaScript context, you need to use something this instead:

TimeRangeSelectedJavaScript="menu.show({start: start, end: end})" 

You can reference "start", "end", and "resource" variables. And you need to pass them wrapped in a single object to .show().

Using "e" will result in a JavaScript error (e is not defined) - you should see it in the JavaScript console.

Comment posted by Stephanie
4 years ago.

Duh! I had that left over from your first post about the context menu on an event. That works. THanks!

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.