This is a migrated thread and some comments may be shown as answers.

Rad Grid -How to get cell (Column) on two different rad grid drag and drop functionality

3 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 29 May 2017, 12:04 PM

Rad Grid - I want to use two rad grid And grid row move one grid to another grid row but I want to need cell .Which cell drop column.

So,How to get cell (Column) on two different rad grid drag and drop functionality

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 May 2017, 12:27 PM
Hello John, 

Thank you for writing.  

RadGridView handles the whole drag and 
drop operation by its RadGridViewDragDropService. You can refer to the following help article demonstrating how to access the drop target element and achieve drag and drop functionality between two RadGridView controls: http://docs.telerik.com/devtools/winforms/gridview/rows/drag-and-drop

I have deleted the other forum thread that you have opened on the same topic in order to avoid duplicated forum threads. 

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
John
Top achievements
Rank 1
answered on 29 May 2017, 12:43 PM

Thanks for reply,

But I want to need drop row Cell. I want to used another way for columns details.

So,how to get drop row specific column cell ?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 May 2017, 08:54 AM
Hello John, 

Thank you for writing back. 

Here is a sample code snippet demonstrating how to handle RadDragDropService.PreviewDropTarget event and replace the drop target with the relevant cell:
public RadForm1()
{
    InitializeComponent();
 
    DataTable dt = new DataTable();
    dt.Columns.Add("Id");
    dt.Columns.Add("Name");
    dt.Columns.Add("Date");
    for (int i = 0; i < 20; i++)
    {
        dt.Rows.Add(i, "Item" + i, DateTime.Now.AddDays(i));
    }
    this.radGridView1.DataSource = dt;
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
 
    var gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
    gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
    gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridBehavior());
    RadDragDropService dragDropService = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
    dragDropService.PreviewDragStart += dragDropService_PreviewDragStart;
    dragDropService.PreviewDragOver += new System.EventHandler<RadDragOverEventArgs>(dragDropService_PreviewDragOver);
    dragDropService.PreviewDragDrop += new System.EventHandler<RadDropEventArgs>(dragDropService_PreviewDragDrop);
    dragDropService.PreviewDropTarget += dragDropService_PreviewDropTarget;
}
 
private void dragDropService_PreviewDropTarget(object sender, PreviewDropTargetEventArgs e)
{
    e.DropTarget = e.HitTarget;
}
 
private void dragDropService_PreviewDragStart(object sender, PreviewDragStartEventArgs e)
{
    e.CanStart = true;
}
 
private void dragDropService_PreviewDragOver(object sender, RadDragOverEventArgs e)
{
    e.CanDrop = true;
}
 
private void dragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
{
    GridDataCellElement dropCellElement = e.HitTarget as GridDataCellElement;
    if (dropCellElement != null)
    {
        Console.WriteLine(dropCellElement.Text);
    }
    //TODO
    e.Handled = true;
}
 
public class CustomGridBehavior : GridDataRowBehavior
{
    protected override bool OnMouseDownLeft(MouseEventArgs e)
    {
        GridDataRowElement row = this.GetRowAtPoint(e.Location) as GridDataRowElement;
        if (row != null)
        {
            RadGridViewDragDropService svc = this.GridViewElement.GetService<RadGridViewDragDropService>();
            svc.AllowAutoScrollColumnsWhileDragging = false;
            svc.AllowAutoScrollRowsWhileDragging = false;
            svc.Start(row);
        }
        return base.OnMouseDownLeft(e);
    }
}

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
John
Top achievements
Rank 1
Share this question
or