How to sync column drag drop between two grids

I have two similar grids which synchronize UI operations. Basically only one grid show the header. Any UI operations on it will be applied to the other grid programmatically

Column dragging is done as below

Event on QueryColumnDragging

  protected void UserControlGrid_OnQueryColumnDragging(object sender, QueryColumnDraggingEventArgs e)
        {
            if (e.Reason == QueryColumnDraggingReason.Dropped)
            {
                var grid1 =sender as SfDataGrid;
                if (ValidateColumnIndex(e.From, grid1 .Columns.Count) &&
                    ValidateColumnIndex(e.To, grid1 .Columns.Count))
                {
                   var grid2 = Grid2;
  var fromColumn = grid2 .Columns[e.From];
                grid2 .Columns.RemoveAt(e.From);
                grid2 .Columns.Insert(e.To < e.From?  e.To +1: e.To, fromColumn);
                }
            }
        }

That works-but with a problem. If the dropped location is not another header row the original grid(grid1 ) wont move the column. So when the header is dropped to a data cell original grid wont move the column, but the second grid will move the column.

How can I resolve this issue?

2 Replies

JV Jimmy Varghese August 14, 2018 09:59 AM UTC

Never mind. Resolved this


DY Deivaselvan Y Syncfusion Team August 14, 2018 10:09 AM UTC

Hi Jimmy,

We are glad to know that you have resolved the reported issue in your application. Please let us know if you need any other assistance.

Regards,
Deivaselvan 


Loader.
Up arrow icon