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

Implement a copy-paste functionality using context menu

Asked by Anonymous
6 months ago.

i am trying to create a copy-paste feature using context menu as displayed here: https://doc.daypilot.org/scheduler/event-copying/

how do i get the following event to fire?

protected void DayPilotScheduler1_Command(object sender, CommandEventArgs e)
{
  switch (e.Command)
  {
    case "paste":
      DateTime pasteHere = (DateTime) e.Data["start"];
      string id = (string) e.Data["id"];

      // find the event using id
      // create a new database record using the original event properties

      DayPilotScheduler1.DataSource = loadEvents(); // your method, load events from database
      DayPilotScheduler1.DataBind();
      DayPilotScheduler1.UpdateWithMessage("Event copied.");
      break;
  }
}

i have added on my daypilot the following:

ContextMenuSelectionID="DayPilotMenuSelection"

AND

<DayPilot:DayPilotMenu ID="DayPilotMenuSelection" runat="server" CssClassPrefix="menu_default">

<DayPilot:MenuItem Action="JavaScript" JavaScript="if (!copied) { alert('You need to copy an event first.'); return; } dps.commandCallBack('paste', {id:copied, start: e.start});" Text="Paste" />

</DayPilot:DayPilotMenu>

do i need to add something more? like oncontextmenuclick = ….

Answer posted by Dan Letecky [DayPilot]
6 months ago.

This is correct. The server-side Command event is fired by the commandCallBack() method (in the menu item action JavaScript).

Comment posted by Anonymous
6 months ago.

thanks for the answer, can you provide me a small sample, i am not sure i got your comment

Comment posted by Dan Letecky [DayPilot]
6 months ago.

The code that you posted above includes everything that is needed. You can see that the commandCallBack() method is used in the JavaScript property of the context menu item.

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