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

Context Menu Not Being Displayed

Asked by Gary
8 years ago.

Hello,

I am trying to implement a event right-click context menu on the day pilot calendar control, this is the code I am using but not menu is being displayed when I right click on an event.

<div class="col-md-10">
<DayPilot:DayPilotMenu ID="dayPilotActionsMenu" runat="server" ClientObjectName="actionsMenu" MenuTitle="Actions" ShowMenuTitle="true">
<DayPilot:MenuItem Text="Delete" Action="Callback" Command="Delete" ToolTip="Delete selected Job/Stage."></DayPilot:MenuItem>
</DayPilot:DayPilotMenu>

<DayPilot:DayPilotCalendar ID="jobCalendarDay" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" ViewType="Day" Visible="false"></DayPilot:DayPilotCalendar>
<DayPilot:DayPilotCalendar ID="jobCalendarWeek" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" ViewType="Week"></DayPilot:DayPilotCalendar>
<DayPilot:DayPilotMonth ID="jobCalendarMonth" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_Month_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" Visible="false" />

</div>

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

I've tried to reproduce the problem using the following testing Web Form but it seems to work fine:

CalendarContextMenu.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CalendarContextMenu.aspx.cs" Inherits="Test_CalendarContextMenu" %>
<%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>
<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <DayPilot:DayPilotMenu ID="dayPilotActionsMenu" runat="server" ClientObjectName="actionsMenu" MenuTitle="Actions" ShowMenuTitle="true"> 
        <DayPilot:MenuItem Text="Delete" Action="Callback" Command="Delete" ToolTip="Delete selected Job/Stage."></DayPilot:MenuItem> 
    </DayPilot:DayPilotMenu>

    <DayPilot:DayPilotCalendar ID="jobCalendarDay" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" ViewType="Day" Visible="false"></DayPilot:DayPilotCalendar> 
    <DayPilot:DayPilotCalendar ID="jobCalendarWeek" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" ViewType="Week"></DayPilot:DayPilotCalendar> 
    <DayPilot:DayPilotMonth ID="jobCalendarMonth" runat="server" ContextMenuID="dayPilotActionsMenu" EventRightClickHandling="ContextMenu" OnEventMenuClick="jobCalendar_EventMenuClick" OnCommand="jobCalendar_Command" OnBeforeEventRender="jobCalendar_Month_BeforeEventRender" EventClickHandling="PostBack" OnEventClick="jobCalendar_DisplayJobInformation" Visible="false" />
    </div>
    </form>
</body>
</html>

CalendarContextMenu.aspx.cs

using System;
using System.Data;
using DayPilot.Web.Ui.Events;
using DayPilot.Web.Ui.Events.Calendar;
using CommandEventArgs = DayPilot.Web.Ui.Events.CommandEventArgs;

public partial class Test_CalendarContextMenu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        jobCalendarWeek.DataSource = GetData();
        jobCalendarWeek.DataStartField = "start";
        jobCalendarWeek.DataEndField = "end";
        jobCalendarWeek.DataIdField = "id";
        jobCalendarWeek.DataTextField = "name";

        DataBind();
    }

    public static DataTable GetData()
    {
        DataTable dt;
        dt = new DataTable();
        dt.Columns.Add("start", typeof (DateTime));
        dt.Columns.Add("end", typeof (DateTime));
        dt.Columns.Add("name", typeof (string));
        dt.Columns.Add("id", typeof (string));

        DataRow dr;

        dr = dt.NewRow();
        dr["id"] = 1;
        dr["start"] = Convert.ToDateTime("15:00");
        dr["end"] = Convert.ToDateTime("16:00");
        dr["name"] = "Event 1";
        dt.Rows.Add(dr);

        return dt;
    }

    protected void jobCalendar_EventMenuClick(object sender, EventMenuClickEventArgs e)
    {
        throw new NotImplementedException();
    }

    protected void jobCalendar_Command(object sender, CommandEventArgs e)
    {
        throw new NotImplementedException();
    }

    protected void jobCalendar_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
    {
    }

    protected void jobCalendar_Month_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Month.BeforeEventRenderEventArgs e)
    {
        throw new NotImplementedException();
    }

    protected void jobCalendar_DisplayJobInformation(object sender, EventClickEventArgs e)
    {
        throw new NotImplementedException();
    }
}

Does this testing page work for you?
Is there any JavaScript error in the browser console?

Comment posted by Gary
8 years ago.

I will try the testing page, the examples app from DP works too just not the web app I am developing. I decided to implement the actions in another way rather then through a context menu which simplfiies the end user interaction so thats a bonus.

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

Gary,

Thanks for the update. It looks like it might be a CSS-related issue. The context menu object is appended at the end of document.body - some of your CSS that changes its visibility or position might get applied to it.

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