Hi, I have a RadGridView with the first 2 columns pinned, and the other columns allow reordering.
The first 2 columns are pinned, but I can move an unpinned column between the pinned columns or to the extreme left, so now I have three pinned columns.
Is it possible to fix this?
Thanks
1 Answer, 1 is accepted
0
Nadya | Tech Support Engineer
Telerik team
answered on 14 Oct 2024, 03:18 PM
Hello, Fabrizio,
In order to prevent dragging columns over pinned ones, you can use the RadDragDropService which is responsible for the drag-drop operations in RadGridVeiw. Then, you should handle the PreviewDragOver event and prevent the drop operation if the hit target is a pinned column.
Please refer to the following code snippet:
RadDragDropService svc = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
privatevoidsvc_PreviewDragOver(object sender, RadDragOverEventArgs e)
{
if (e.HitTarget is GridHeaderCellElement)
{
GridHeaderCellElement headerCell = e.HitTarget as GridHeaderCellElement;
if (headerCell.ColumnInfo.IsPinned)
{
e.CanDrop = false;
}
}
}
Thus, you shouldn't be allowed to insert a column between pinned columns:
I hope this helps. If you have other questions, please let me know.
Regards,
Nadya | Tech Support Engineer
Progress Telerik