Hi,
Let me first start by saying I like your controls and products. I am implementing a RadGrid and Scheduler with the idea of dragging and dropping rows from the grid and placing them on the scheduler. I am using the following demo as a guideline:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/draganddropintegration/defaultcs.aspx?product=scheduler
The issue I am having is that in your example you are filling the rad grid with task data whose data table has an ID column with an int data type. When you drop the row over the grid it appears to use that integer ID field as the appointment id and places a new appointment in the index.
Like this:
However I am trying to add a list of users to the list where the ID column is unique identifier (Guid). After I dropping the even on the scheduler everything seems to work fine up until I get to the the callback OnDataSourceOperationComplete(), where i get an error stating that the key must be of the ienumerbale type.
Here is my code again with the int datatype changed to Guid:
Unfortunately I am not sure how to overcome this.
Can you provide an example perhaps of how to drag and drop items that have a non integer ID column data type? Or if this is even possible?
Thanks,
-Justin
Let me first start by saying I like your controls and products. I am implementing a RadGrid and Scheduler with the idea of dragging and dropping rows from the grid and placing them on the scheduler. I am using the following demo as a guideline:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/draganddropintegration/defaultcs.aspx?product=scheduler
The issue I am having is that in your example you are filling the rad grid with task data whose data table has an ID column with an int data type. When you drop the row over the grid it appears to use that integer ID field as the appointment id and places a new appointment in the index.
Like this:
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e)
{
GridDataItem dataItem = e.DraggedItems[0];
Hashtable values = new Hashtable();
dataItem.ExtractValues(values);
(int)dataItem.GetDataKeyValue("ID");
string firstName = (string)values["FirstName"];
string lastName = (string)values["LastName"];
string targetSlotIndex = TargetSlotHiddenField.Value;
if (targetSlotIndex != string.Empty)
{
HandleSchedulerDrop(id, firstName, targetSlotIndex);
TargetSlotHiddenField.Value = string.Empty;
}
RadScheduler1.Rebind();
rgGridViewUsers.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));
}
private void ScheduleAppointment(int id, string subject, DateTime start, DateTime end)
{
IDataSource dataSource = SchedulerDataSource;
DataSourceView view = dataSource.GetView("DefaultView");
IOrderedDictionary data = new OrderedDictionary();
data.Add("Subject", subject);
data.Add("Start", start);
data.Add("End", end);
IDictionary keys = new OrderedDictionary();
keys.Add("ID", id);
//keys.Add("ID", 234);
view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete);
}
private static bool OnDataSourceOperationComplete(int count, Exception e)
{
if (e != null)
{
throw e;
}
return true;
}
However I am trying to add a list of users to the list where the ID column is unique identifier (Guid). After I dropping the even on the scheduler everything seems to work fine up until I get to the the callback OnDataSourceOperationComplete(), where i get an error stating that the key must be of the ienumerbale type.
Here is my code again with the int datatype changed to Guid:
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e)
{
GridDataItem dataItem = e.DraggedItems[0];
Hashtable values = new Hashtable();
dataItem.ExtractValues(values);
Guid id = new Guid((string)values["ID"]);//(int)dataItem.GetDataKeyValue("ID");
string firstName = (string)values["FirstName"];
string lastName = (string)values["LastName"];
string targetSlotIndex = TargetSlotHiddenField.Value;
if (targetSlotIndex != string.Empty)
{
HandleSchedulerDrop(id, firstName, targetSlotIndex);
TargetSlotHiddenField.Value = string.Empty;
}
RadScheduler1.Rebind();
rgGridViewUsers.Rebind();
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadScheduler1);
}
private void HandleSchedulerDrop(Guid 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));
}
private void ScheduleAppointment(Guid id, string subject, DateTime start, DateTime end)
{
IDataSource dataSource = SchedulerDataSource;
DataSourceView view = dataSource.GetView("DefaultView");
IOrderedDictionary data = new OrderedDictionary();
data.Add("Subject", subject);
data.Add("Start", start);
data.Add("End", end);
IDictionary keys = new OrderedDictionary();
keys.Add("ID", id);
//keys.Add("ID", 234);
view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete);
}
private static bool OnDataSourceOperationComplete(int count, Exception e)
{
if (e != null)
{
throw e;
}
return true;
}
Unfortunately I am not sure how to overcome this.
Can you provide an example perhaps of how to drag and drop items that have a non integer ID column data type? Or if this is even possible?
Thanks,
-Justin