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

external drag and drop

Asked by Rajitha
4 years ago.

how can i drag and drop event and store it in database using asp.net

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

The following tutorial shows how to use external drag and drop in a real-world scenario:
http://code.daypilot.org/51743/courtroom-schedule-tutorial-asp-net-c-vb-net

In most cases you will already have the "unscheduled" items from the external list stored in the DB. You can also detect an external drag and drop using "external" variable in EventMoveJavaScript.

See also:
http://doc.daypilot.org/scheduler/external-drag-and-drop/

Comment posted by Teja
4 years ago.

Thank you for your great answer sir!

if ((bool)e.Data["external"])
{
new DataManager().CreateAssignment(e.NewStart, e.NewEnd, Convert.ToInt32(e.NewResource), Convert.ToInt32(e.Value));
DayPilotScheduler1.UpdateWithMessage("The assignment has been created.");
}
// moving an existing assignment
else
{
new DataManager().MoveAssignment(Convert.ToInt32(e.Value), e.NewStart, e.NewEnd, e.NewResource);
DayPilotScheduler1.UpdateWithMessage("The assignment has been updated.");
}

only this part is enough to drag external events and store in database?

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

Yes, the external drag and drop will fire the standard EventMove event.

Comment posted by Teja
4 years ago.

Thanks again

Comment posted by Teja
4 years ago.

is it possible to drag and drop the external events to the database without using popup

Comment posted by Teja
4 years ago.

protected void DayPilotScheduler1_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e)
{
string id = e.Value;
DateTime start = e.NewStart;
DateTime end = e.NewEnd;
string resource = e.NewResource;
DbUpdateEvent(id, start, end);
DayPilotScheduler1.DataSource = DbGetEvents(DayPilotScheduler1.StartDate, DayPilotScheduler1.Days);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.UpdateWithMessage("Event moved");
}

by using the above code, the events inside the scheduler is moving. but not the external events. can i please get the code for adding external events in database

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

If the event doesn't exist in the DB yet it can't be updated with DbUpdateEvent() because it does something like this:

UPDATE events SET start = @start, end = @end WHERE id = @id;

That's why the sample above detects the external drag and drop and creates the event instead of updating it.

But this depends on your architecture. As I noted, one of the options is to have the unscheduled events in the database already.

Comment posted by Teja
4 years ago.

i do have the unscheduled events from database. but the problem is dragging and dropping unscheduled is not happenning

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