radgridview pinned columns & Reorder

1 Answer 44 Views
GridView
fabrizio
Top achievements
Rank 1
Iron
fabrizio asked on 14 Oct 2024, 01:10 PM

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

Sort by
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>();
private void svc_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

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
fabrizio
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or