This is a migrated thread and some comments may be shown as answers.
Advanced drag and drop questions
4 Answers 50 Views
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 03 Dec 2009, 06:58 PM
I have a RadScheduler with a RadGrid, utilizing the drag and drop from the grid to the scheduler. All works great! (Thanks for the good online example)

I am also utilizing resources in the scheduler. Is there a way to map the dropped item to the proper resource it was dropped into? Currently I am mapping the name fields and the time slots are being set by the HandleSchedulerDrop method. I want to do all the above and have it know which resource I dropped it into. Is this possible?

Secondarily I have other fields associated with the scheduler item that are not in the grid item. So I want the user to enter those values when they drop the grid item into the scheduler. To do this, I envision the advanced edit form opening on drop. I have the StartEditingInAdvancedForm set to true, so I assume all I need to do is put the scheduler in edit mode for that item. Is this possible?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Dec 2009, 02:11 PM
Hello Joe,

Referencing the drag and drop demo, you can access the resource in HandleSchedulerDrop as follows:

private void HandleSchedulerDrop(int id, string subject, string targetSlotIndex)
        {
            RadScheduler1.Rebind();
            ISchedulerTimeSlot slot = RadScheduler1.GetTimeSlotFromIndex(targetSlotIndex);
            TimeSpan duration = TimeSpan.FromHours(1);
            if (slot.Duration == TimeSpan.FromDays(1))
            {
                duration = slot.Duration;
            }
            ScheduleAppointment(id, subject, slot.Start, slot.Start.Add(duration), Convert.ToInt16(slot.Resource.Key));
        }

To open the edit form of the appointment after drop on the scheduler area, modify the code like this (changes are highlighted):
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e)
        {
            GridDataItem dataItem = e.DraggedItems[0];
  
            Hashtable values = new Hashtable();
            dataItem.ExtractValues(values);
  
            int id = (int) dataItem.GetDataKeyValue("AppointmentID");
            string subject = (string) values["Subject"];
            string targetSlotIndex = TargetSlotHiddenField.Value;
  
            if (targetSlotIndex != string.Empty)
            {
                HandleSchedulerDrop(id, subject, targetSlotIndex);
                TargetSlotHiddenField.Value = string.Empty;
            }
            //RadScheduler1.Rebind();
            RadGrid1.Rebind();
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadScheduler1);
        }
  
        private void HandleSchedulerDrop(int id, string subject, string targetSlotIndex)
        {
            RadScheduler1.Rebind();
  
            ISchedulerTimeSlot slot = RadScheduler1.GetTimeSlotFromIndex(targetSlotIndex);
  
            TimeSpan duration = TimeSpan.FromHours(1);
            if (slot.Duration == TimeSpan.FromDays(1))
            {
                duration = slot.Duration;
            }
            ScheduleAppointment(id, subject, slot.Start, slot.Start.Add(duration));
  
            RadScheduler1.DataBind();
  
            RadScheduler1.ShowAdvancedEditForm(RadScheduler1.Appointments.FindByID(id));
        }

Let us know if we can be of further assistance.


Best wishes,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Joe
Top achievements
Rank 1
answered on 11 Dec 2009, 06:36 PM
Peter,

Thanks for the great information!
0
Stanley
Top achievements
Rank 1
answered on 05 Jan 2010, 07:13 AM
Hi Peter,
Could you please also post the code of your modified (added one more input param) version of ScheduleAppointment() ?
Thanks!
0
Dimitar Milushev
Telerik team
answered on 07 Jan 2010, 03:30 PM
Hello Stanley,

Basically you should change the function signature:

    private void ScheduleAppointment(int id, string subject, DateTime start, DateTime end, int resourceID)

and add the key to the row data to be updated:

            IOrderedDictionary data = new OrderedDictionary();
            data.Add("Subject", subject);
            data.Add("Start", start);
            data.Add("End", end);
            data.Add("MyResourceID", resourceID);



All the best,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Asked by
Joe
Top achievements
Rank 1
Answers by
Peter
Telerik team
Joe
Top achievements
Rank 1
Stanley
Top achievements
Rank 1
Dimitar Milushev
Telerik team
Share this question
or