I can no longer drag a column header to the group by box at the top. Not sure when this stopped working. When I click on the column header it is highlighted, but I can not drag it. Does it have something to do with the drag and drop of rows I added to my app. I am using your provided service for the row drag and drop. I believe I have everything enabled.
dgvFiles.ShowGroupPanel = true;
this.dgvFiles.AllowSearchRow = true;
dgvFiles.Columns[1].AllowGroup = false; // prevent grouping of Path Column
dgvFiles.Columns[2].AllowGroup = true;//filename
dgvFiles.Columns[3].AllowGroup = true;// length
dgvFiles.Columns[4].AllowGroup = true; // catagory
4 Answers, 1 is accepted
According to the provided information, it seems that you have custom implementation for the drag and drop behavior. I suppose that you are using the approach demonstrated here: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/drag-and-drop
If the grouping is enabled on your end, you need to do 2 small modifications in the code to keep the default grouping functionality. The RadDragDropService's PreviewDragOver and PreviewDragDrop events are illustrated below:
private void svc_PreviewDragOver(object sender, RadDragOverEventArgs e)
{
if (e.DragInstance is GridDataRowElement)
{
Console.WriteLine(e.HitTarget);
e.CanDrop = e.HitTarget is GridDataRowElement ||
e.HitTarget is GridTableElement ||
e.HitTarget is GridSummaryRowElement ||
e.HitTarget is GroupPanelElement;
}
}
private void svc_PreviewDragDrop(object sender, RadDropEventArgs e)
{
var rowElement = e.DragInstance as GridDataRowElement;
if (rowElement == null)
{
return;
}
if (e.HitTarget is GroupPanelElement)
{
e.Handled = false;
}
else
{
e.Handled = true;
var dropTarget = e.HitTarget as RadItem;
var targetGrid = dropTarget.ElementTree.Control as RadGridView;
if (targetGrid == null)
{
return;
}
var dragGrid = rowElement.ElementTree.Control as RadGridView;
if (targetGrid != dragGrid)
{
e.Handled = true;
//append dragged rows to the end of the target grid
int index = targetGrid.RowCount;
//Grab every selected row from the source grid, including the current row
List<GridViewRowInfo> rows =
dragGrid.SelectedRows.ToList<GridViewRowInfo>();
if (dragGrid.CurrentRow != null)
{
GridViewRowInfo row = dragGrid.CurrentRow;
if (!rows.Contains(row))
rows.Add(row);
}
this.MoveRows(targetGrid, dragGrid, rows, index);
}
}
}
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
If I change the e.CanStart from false to true all worked fine
else
{
e.CanStart = true;
}
private void svc_PreviewDragStart(object sender, PreviewDragStartEventArgs e)
{
GridDataRowElement draggedRowElement = e.DragInstance as GridDataRowElement;
if (draggedRowElement != null && draggedRowElement.RowInfo != null)
{
e.CanStart = true;
draggedRow = draggedRowElement.RowInfo;
}
else
{
e.CanStart = true;
}
The PreviewDragStart event of the RadGridViewDragDropService fires when the drag and drop operation is about to be started. In the PreviewDragStartEventArgs you have access to the DragInstance. You can control whether the service should be started or not for this element by the CanStart argument.
According to the provided code snippet, you can leave only setting the CanStart argument to true. You don't need the if-else construction here if you are not going to restrict starting the drag operation.
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.