We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Drag and drop doesn't always drop row to the indicated drop position

When dragging-and-dropping a row lower down in a Xamarin Forms SfDataGrid, the row is inserted one position lower than the indicated drop position. This is reproducible in the Sample Browser. It works correctly when dragging higher up the list.

The QueryRowDraggingEventArgs .To parameter in the QueryRowDraggingEvent is similarly off by one when dragging down (except when dropping below the last row).


4 Replies

DS Divakar Subramaniam Syncfusion Team February 10, 2017 07:21 AM UTC

Hi Andrew, 
 
 
We have considered your query as a defect and we are currently working on it.  
 
A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates    
 
 
Regards, 
Divakar. 
 



EM Emil March 1, 2017 01:36 PM UTC

As i know sfdatagrid Starts from row number =1 instead of 0. Did you check that?


AM Andrew Macdonald March 1, 2017 10:49 PM UTC

Emil,

Yes, it wasn't that. The interface drag-and-drop had a bug which Syncfusion has fixed and will be available in the 2017 Volume 1 SP1 release.

However the code-behind QueryRowDraggingEventArgs.To parameter still has the same unexpected behavior. That is, it returns the same index value when dropping below either the second-last row or the last row of the Grid. SyncFusion provided a solution that uses the QueryRowDraggingEventArgs.Position.Y parameter to distinguish those two scenarios. Here's the code in case it's useful to anyone else.

public int LastIndex 

    get 
    { 
        return (dataGrid.GroupColumnDescriptions.Count > 0 
            ? this.dataGrid.View.TopLevelGroup.DisplayElements.Count 
            : this.dataGrid.View.Records.Count); 
    } 

 
private void DataGrid_QueryRowDragging(object sender, QueryRowDraggingEventArgs e) 

    if (e.Reason == QueryRowDraggingReason.Dragging) 
    { 
        var totalHeight = dataGrid.RowColumnIndexToPoint(new RowColumnIndex(this.LastIndex, 0)).Y + this.dataGrid.RowHeight; 
        if (Math.Ceiling(e.Position.Y + (dataGrid.RowHeight * 0.45)) 
            > totalHeight && e.To == LastIndex) 
        { 
            // Will hit if RowDragView move below the last row.  
        } 
    } 



VP Vimal Prabhu Manohkaran Syncfusion Team March 2, 2017 09:03 AM UTC

Hi Emil,

As stated by Andrew, the fix for the reported issue is available in the 2017 Volume 1 Service Pack 1 release. Hence requesting you to update the Syncfusion nugets to the latest version. Also, please use the below workaround to achieve your requirement of getting notification when dragged below the last row. We are currently preparing UG documentation for the same which will be updated at the earliest. 
 
  
Andrew, thank you for the time and efforts for coming up with that reply to Emile.  

Regards,
Vimal Prabhu


Loader.
Live Chat Icon For mobile
Up arrow icon