I am using the Drag and Drop integration example. When I drag a row from the RadGrid onto the scheduler while the scheduler is group by resources I get the error "Resource index out of range: 1". This is the sample default.aspx.cs code I am trying to use. I have noted that when grouped by resources the slotTargetindex format goes from "1:0:0" to "0:1:0:0". Any help would be appreciated.
Thanks, Tom
Thanks, Tom
| 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), slot.Resource); |
| } |
| protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e) |
| { |
| if (e.CommandName == "Unschedule") |
| { |
| int id = (int)e.Container.Appointment.ID; |
| DateTime dueDate = DateTime.Now; |
| if (!string.IsNullOrEmpty(e.Container.Appointment.Attributes["Due"])) |
| dueDate = Convert.ToDateTime(e.Container.Appointment.Attributes["Due"]); |
| string priority = "Medium"; |
| if (!string.IsNullOrEmpty(e.Container.Appointment.Attributes["Priority"])) |
| priority = e.Container.Appointment.Attributes["Priority"]; |
| UnscheduleAppointment(id, dueDate, priority); |
| RadScheduler1.Rebind(); |
| RadGrid1.Rebind(); |
| RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadScheduler1, RadGrid1); |
| } |
| } |
| private void UnscheduleAppointment(int id, DateTime dueDate, string priority) |
| { |
| IDataSource dataSource = SqlDataSource2; |
| DataSourceView view = dataSource.GetView("DefaultView"); |
| IOrderedDictionary data = new OrderedDictionary(); |
| data.Add("Start", null); |
| data.Add("End", null); |
| data.Add("Due", dueDate); |
| data.Add("Priority", priority); |
| IDictionary keys = new OrderedDictionary(); |
| keys.Add("AppointmentID", id); |
| view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete); |
| } |
| private void ScheduleAppointment(int id, string subject, DateTime start, DateTime end, Resource res) |
| { |
| IDataSource dataSource = SqlDataSource1; |
| DataSourceView view = dataSource.GetView("DefaultView"); |
| IOrderedDictionary data = new OrderedDictionary(); |
| data.Add("Subject", subject); |
| data.Add("Start", start); |
| data.Add("End", end); |
| data.Add("employeeid", res); |
| IDictionary keys = new OrderedDictionary(); |
| keys.Add("AppointmentID", id); |
| view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete); |
| } |
| private static bool OnDataSourceOperationComplete(int count, Exception e) |
| { |
| if (e != null) |
| { |
| throw e; |
| } |
| return true; |
| } |