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

4 posts, 0 answers
  1. John
    John avatar
    19 posts
    Member since:
    May 2017

    Posted 29 May 2017 Link to this post

    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

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3532 posts

    Posted 29 May 2017 Link to this post

    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.
  3. John
    John avatar
    19 posts
    Member since:
    May 2017

    Posted 29 May 2017 Link to this post

    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 ?

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3532 posts

    Posted 30 May 2017 Link to this post

    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.
Back to Top