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?