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

How do I show context menu on Highlight event?

Asked by Alex
16 years ago.
I would like to show context menu when use click somewhere, is it possible?
Comment posted by Dan Letecky
16 years ago.
Yes, it's possible.

The context menu is available in the following scenarios:

1. On right click on a time range selection (including right-clicking somewhere)
You have to set TimeRangeSelectedHandling="Hold" and assign the context menu to ContextMenuSelectionID.

2. On right-clicking an event
Just assign ContextMenuID for global context menu (for all events). You can set context menu for each event individually in BeforeEventRender event handler.

3. Invoke context menu manually
Use menu1.show(e) method where "menu1" is ClientObjectName of the menu and e is the DayPilotCalendar.Event/DayPilotScheduler.Event object (available in client-side event handlers as "e").
Comment posted by Alex
16 years ago.
Thanks for quick replay Dan. Actualy I just want to be able to see context menu on TimeRangeSelectedHandling when user click somewhere in calendar and if I use JavaScript with script like: dpc.show(e) I get error about that 'e' is undefined?
Comment posted by giamix
16 years ago.
I'm also facing the same problem. I use the TimeRangeSelectedHandling="JavaScript" in conjunction with TimeRangeSelectedJavaScript="menuCreate.show(e)" where menuCreate is the clientobjectname of the contextmenu and i'm getting the same error." e is undefined."
Comment posted by Dan Letecky
16 years ago.
Alex,
Sorry for a late response.

Alex, giamix,
e is not valid in this context (it holds the Event object for event-related user actions). For time-range related context menu you should supply the Selection object which you can get using dpc.getSelection(). So it should look like this:

menuCreate.show(dpc.getSelection())

Where dpc is the value of DayPilotCalendar.ClientObjectName property. Let me know if you have troubles with this code.
Comment posted by DL
14 years ago.

I'm trying to pop a menu on TimeRangeSelected from DPMonthly as mentioned above - "menuCreate.show(dpc.getSelection())" - but getSelection doesn't seem to exist on the monthly calendar - is there any way to pop up a context menu on a left click on a day within DPMonth?

Comment posted by Dan Letecky
14 years ago.

You can use the following code for DayPilot Month:

function invokeMenu(start) {
 var selection = new DayPilot.Selection(start, start.addDays(1), null, dpm);
 menuCreate.show(selection);
}

TimeRangeSelected event must be handled on the client side:

TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="invokeMenu(start)"
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.