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

Object expected when pasting an event in Scheduler

Asked by Andy Woodward
11 years ago.

Hi,
When copying & pasting an event I'm getting an error saying object expected.
In debug mode it is this line creating the error
v.items = [{'text':'Paste', 'onclick':function() { var e = this.source; var command = this.item.command; if (!copied) { alert('You need to copy an event first.'); return; } commandCallBack('paste', {id:copied, start: e.start});

I think it may be the code in DayPilotScheduler1_Command

Code is

protected void DayPilotScheduler1_Command(object sender, DayPilot.Web.Ui.Events.CommandEventArgs e)
{
switch (e.Command)
{
case "refresh":
DayPilotScheduler1.DataSource = dbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();
break;
case "filter":
LoadResources();
DayPilotScheduler1.DataSource = dbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();
break;
case "navigate":
DateTime start = (DateTime)e.Data["start"];
DateTime end = (DateTime)e.Data["end"];

DayPilotScheduler1.StartDate = start;
// DayPilotScheduler1.DataBind();
DayPilotScheduler1.DataSource = dbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update(CallBackUpdateType.Full);
break;
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 = dbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days); // your method, load events from database
DayPilotScheduler1.DataBind();
DayPilotScheduler1.UpdateWithMessage("Event copied.");
break;
}

DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update(CallBackUpdateType.Full);

Please help

Andy

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

It looks like you might be missing the DayPilot object reference when calling commandCallBack:

v.items = [{'text':'Paste', 'onclick':function() { var e = this.source; var command = this.item.command; if (!copied) { alert('You need to copy an event first.'); return; } dps.commandCallBack('paste', {id:copied, start: e.start});

"dps" is the ClientObjectName value.

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