Hi,
When I drag/drop an event, it calls the backend save function properly on drop. However if I drag and drop that same event, it won’t call the Save backend function a second time. It seems to be returning from this line in the .js sendData function:
if (this._in_progress[a]) return !1;
Here is my save data function, it’s been updated per responses in the forum for 5.1 compatibility:
public ContentResult Save(CalendarEvent changedEvent, FormCollection actionValues)
{
var action = new DataAction(actionValues);
action.TargetId = changedEvent.id;
switch (action.Type)
{
case DataActionTypes.Insert:
SaveEvent(CalendarAction.Insert, changedEvent, action);
break;
case DataActionTypes.Update:
SaveEvent(CalendarAction.Update, changedEvent, action );
break;
case DataActionTypes.Delete:
SaveEvent(CalendarAction.Delete, changedEvent, action );
break;
}
return Content((new AjaxSaveResponse(action)));
}
Hi,
if you create a new event by drag and drop, make sure you return a database id of an inserted record to the client-side:
//after event is inserted into db, changedEvent.id contains a permanent id
action.TargetId = changedEvent.id;Otherwise client-side will be using temporary id, generated during creating event on the page, and changes won’t be applied to needed db record
Hi,
Thanks for the reply. After digging further. It turns out that I’m interrupting the process because with onEventChanged, I refresh the calendar. I think it is stepping on things before they are done being initialized from the Save.
scheduler.attachEvent("onEventChanged", function (id) {
alert("onEventChanged");
reload();
});
function reload() {
scheduler.clearAll();
scheduler.load("@Model.Scheduler.DataUrl" + "StudentID=" + document.getElementById("StudentID").value);
}
So I guess this isn’t the best way of doing this. When the user drags and drops, I tweak the start time on the backend save function, and possibly move other events, so i want to “reload” the data in the calendar after a pop save or drag and drop. What is the best way to do this?
Thanks
Mike
Hi,
got it. Seems like you reloading the page before ajax update is completed (onEventChanged triggers when event is updated on the client side, it is not saved to the server yet). So, when you reload the page while ajax is still sending it might never be actually sent to the server.
Try listening an event that fired when changes are confirmed from the server. Also, instead of reloading the whole page, you can refresh only the data, using client-side apischeduler.dataProcessor.attachEvent("onAfterUpdate", function (sid, action, tid, tag){
setTimeout(function (){// right now I can't check whether setTimeout is really necessary, you can try without it
scheduler.clearAll();
scheduler.load('@Url.Action("Data")', 'json');
}, 1);
});
related links- viewtopic.php?f=25&t=27673&p=87730&hilit=onAfterUpdate#p87730 docs.dhtmlx.com/scheduler/api__s … arall.html docs.dhtmlx.com/scheduler/api__s … _load.html docs.dhtmlx.com/api__dataprocess … event.html
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan