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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drag and Drop Between SfdataGrid Issue

Thread ID:

Created:

Updated:

Platform:

Replies:

142340 Jan 29,2019 08:51 AM UTC Feb 1,2019 07:16 AM UTC WPF 3
loading
Tags: SfDataGrid
Brijesh
Asked On January 29, 2019 08:51 AM UTC

Hello Team,

In the below link Drag and drop between SFDatagrid happen but I want to do some operation at the time of drop from one grid to another grid. Is there any event where we can get the drop position with the record and the grid which initiated the drag?

Thanks
Harshul



Jayaleshwari N [Syncfusion]
Replied On January 30, 2019 10:47 AM UTC

Hi Harshul, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked the reported query “Is there any event where we can get the drop position with the record and the grid which initiated the drag” from our side. You can make use of Dragging and Dropped event of RowDragAndDropController. 
 
Code snippet: Event to know the datagrid which initiated the drag. You can get the initiated datagrid form sender. 
 
this.dataGrid1.RowDragDropController.DragStart += RowDragDropController_DragStart; 
private void RowDragDropController_DragStart(object sender, Syncfusion.UI.Xaml.Grid.GridRowDragStartEventArgs e) 
{ 
             
} 
 
Code snippet: Event to know that the drop position from the event args of Dropped event. 
 
this.dataGrid2.RowDragDropController.Dropped += RowDragDropController_Dropped; 
 
private void RowDragDropController_Dropped(object sender, Syncfusion.UI.Xaml.Grid.GridRowDroppedEventArgs e) 
{ 
             
} 
 
Please find the details about GridRowDroppedEventArgs details 
 
  • Data : Gets or sets a data object that contains the data associated when dragging the rows.
  • DropPosition : Gets a value that indicates the drop position based on the dropped location.   
  • IsFromOutSideSource : Gets a value that indicates whether the dragging item is from the same datagrid
  • TargetRecord: Gets a value that indicates the target record, which is going to be dropped
 
We already have a task to update the Drag and Drop with data grid in our user guide documentation. We will shortly update the documentation. 
 
Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N. 


Brijesh
Replied On January 31, 2019 10:22 AM UTC

Hi,

In the below sample how will we get drop location and record(data) in the second grid in which I have applied below event. please update below sample.

this.dataGrid2.RowDragDropController.Dropped += RowDragDropController_Dropped; 
 
private void RowDragDropController_Dropped(object sender, Syncfusion.UI.Xaml.Grid.GridRowDroppedEventArgs e) 
{ 
             
} 
Thanks 
Harshul

Jayaleshwari N [Syncfusion]
Replied On February 1, 2019 07:16 AM UTC

Hi Harshul, 
 
Sorry for the inconvenience. 
 
We have modified the sample to achieve your requirement by using RowDragDropController. You will get dropped record, dropped location and source that initiated the dragging in ProcessOndrop override method. 
 
Code snippet C#: dropped record, location and initiated source get in ProcessOnDrop method. 
 
public class RowDragDropControllerExt : GridRowDragDropController 
{                 
    protected override void ProcessOnDrop(DragEventArgs args, RowColumnIndex rowColumnIndex) 
    { 
        base.ProcessOnDrop(args, rowColumnIndex); 
        var dropPosition = args.GetPosition(this.DataGrid);     // drop location dragged record.        
        var record = this.DataGrid.GetRecordAtRowIndex(rowColumnIndex.RowIndex);    // Dropped record. 
        if (args.Data.GetDataPresent("SourceDataGrid")) 
        { 
            var sourceDataGrid = args.Data.GetData("SourceDataGrid") as SfDataGrid;      // DataGrid that initated event. 
        } 
    }         
} 
                               
Code snippet C#: Extended RowDragDropControllerExt assigned to DataGrid’s RowDragDropController. 
 
public class SfDataGridBehavior   : Behavior<SfDataGrid> 
{ 
    protected override void OnAttached() 
    { 
        base.OnAttached(); 
        this.AssociatedObject.RowDragDropController = new RowDragDropControllerExt(); 
    } 
} 
 
We have attached the tested sample for your reference and you can download the same from the following location. 
 
Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon