I am working off of the demo code for Rad Grid drag and drop functionality, and I cannot seem to get any values in the DraggedItems collection on the RowDrop server event.
In the following code, e.HtmlElement = "" and e.DraggedItems.Count = 0. Has anyone run into the same issue? Am I missing something here. I do not need to use any of the client events, so nothing is being affected by OnRowDropping. I am basically just dragging to reorder within the grid. Any help would be appreciated.
FYI, this grid is within a user control within an ASP.NET Ajax Tab Control, not the telerik tab control. The UI does not reflect the item that I am dragging, when I am dragging it. It just shows an thin line (like an empty row). If I drag off of the grid, then select another item, and drag again, it will show an item being dragged and the code below works fine, then if I try again it does not.
Protected Sub grdQuoteDetails_RowDrop(ByVal sender As Object, ByVal e As GridDragDropEventArgs)
If String.IsNullOrEmpty(e.HtmlElement) Then
If e.DraggedItems(0).OwnerGridID = grdQuoteDetails.ClientID Then
' items are drag from quote details
If e.DestDataItem IsNot Nothing AndAlso e.DestDataItem.OwnerGridID = grdQuoteDetails.ClientID Then
'reorder items in pending grid
Dim pendingDetails As IList(Of Model.QuoteDetail)
pendingDetails = PendingQuoteDetails
Dim quoteDetail As Model.QuoteDetail = GetQuoteDetail(pendingDetails, DirectCast(e.DestDataItem.GetDataKeyValue("ID"), Integer))
Dim destinationIndex As Integer = pendingDetails.IndexOf(quoteDetail)
If ((e.DropPosition = GridItemDropPosition.Above) _
AndAlso (e.DestDataItem.ItemIndex > e.DraggedItems(0).ItemIndex)) Then
destinationIndex = (destinationIndex - 1)
End If
If ((e.DropPosition = GridItemDropPosition.Below) _
AndAlso (e.DestDataItem.ItemIndex < e.DraggedItems(0).ItemIndex)) Then
destinationIndex = (destinationIndex + 1)
End If
Dim detailsToMove As New List(Of Model.QuoteDetail)()
For Each draggedItem As GridDataItem In e.DraggedItems
Dim tmpDetail As Model.QuoteDetail = GetQuoteDetail(pendingDetails, DirectCast(draggedItem.GetDataKeyValue("ID"), Integer))
If tmpDetail IsNot Nothing Then
detailsToMove.Add(tmpDetail)
End If
Next
For Each detailToMove As Model.QuoteDetail In detailsToMove
pendingDetails.Remove(detailToMove)
pendingDetails.Insert(destinationIndex, detailToMove)
Next
PendingQuoteDetails = pendingDetails
grdQuoteDetails.Rebind()
End If
End If
End If
End Sub
Grid sorts by a column that is defined as string in the datasource. As a result, the order of the groups is like this:
Group 1
Group 10
Group 11
Group 2
Group 3
I cannot change the column type in the datasource because it might break too many other things. Adding
<telerik:GridTemplateColumn DataType="System.Int32"
<
telerik:RadOrgChart
ID
=
"radOrgChart"
runat
=
"server"
GroupColumnCount
=
"4"
DisableDefaultImage
=
"true"
Skin
=
"Sitefinity"
>
<
RenderedFields
>
<
ItemFields
>
<
telerik:OrgChartRenderedField
DataField
=
"FullName"
/>
<
telerik:OrgChartRenderedField
DataField
=
"Title"
/>
<
telerik:OrgChartRenderedField
DataField
=
"ProfileLink"
/>
</
ItemFields
>
</
RenderedFields
>
</
telerik:RadOrgChart
>
//Table to define the nodes
DataTable nodeTable =
new
DataTable();
nodeTable.Columns.Add(
"ID"
);
nodeTable.Columns.Add(
"ManagerID"
);
//Table to hold the data for the items
DataTable itemsTable =
new
DataTable();
itemsTable.Columns.Add(
"NodeID"
);
itemsTable.Columns.Add(
"ID"
);
itemsTable.Columns.Add(
"FullName"
);
itemsTable.Columns.Add(
"Title"
);
itemsTable.Columns.Add(
"ProfileLink"
);
//Get Contacts Manager
var tmpCM = ContactMgr.GetContactByID(ContactToDisplay.ManagerID);
//Get Contacts Managers manager
var tmpCMM = ContactMgr.GetContactByID(tmpCM.ManagerID);
//Get Contacts Managers employees
var tmpCME = ContactMgr.GetEmployeesByManagerID(tmpCM.ID);
//Add the nodes to the nodesTable
nodeTable.Rows.Add(
new
string
[] {
"1"
,
null
});
nodeTable.Rows.Add(
new
string
[] {
"2"
,
"1"
});
nodeTable.Rows.Add(
new
string
[] {
"3"
,
"2"
});
//Add the details of the employees to the itemTable
itemsTable.Rows.Add(
new
string
[] {
"1"
, tmpCMM.ID.ToString(),
"<b>"
+ tmpCMM.FullName +
"</b>"
, tmpCMM.Title,
"<a href='/contacts/detail.aspx?id="
+ tmpCMM.ID +
"'>View Details</a>"
});
itemsTable.Rows.Add(
new
string
[] {
"2"
, tmpCM.ID.ToString(),
"<b>"
+ tmpCM.FullName +
"</b>"
, tmpCM.Title,
"<a href='/contacts/detail.aspx?id="
+ tmpCM.ID +
"'>View Details</a>"
});
foreach
(Directory_BO.Contact tmpC
in
tmpCME)
itemsTable.Rows.Add(
new
string
[] {
"3"
, tmpC.ID.ToString(),
"<b>"
+ tmpC.FullName +
"</b>"
, tmpC.Title,
"<a href='/contacts/detail.aspx?id="
+ tmpC.ID +
"'>View Details</a>"
});
//Setup the relationships within the OrgChart
radOrgChart.GroupEnabledBinding.NodeBindingSettings.DataFieldID =
"ID"
;
radOrgChart.GroupEnabledBinding.NodeBindingSettings.DataFieldParentID =
"ManagerID"
;
radOrgChart.GroupEnabledBinding.NodeBindingSettings.DataSource = nodeTable;
radOrgChart.GroupEnabledBinding.GroupItemBindingSettings.DataFieldNodeID =
"NodeID"
;
radOrgChart.GroupEnabledBinding.GroupItemBindingSettings.DataFieldID =
"ID"
;
radOrgChart.GroupEnabledBinding.GroupItemBindingSettings.DataSource = itemsTable;
//Bind the OrgChart
radOrgChart.DataBind();