Auto Scrolling When Performing Drag and Drop between GridViews

2 posts, 1 answers
  1. Joe
    Joe avatar
    3 posts
    Member since:
    Apr 2011

    Posted 01 Jan 2020 Link to this post

    I've implemented drag and drop between two RadGridViews using RadGridViewDragDropService.

    This works well, but I can't get Auto Scrolling to work when dragging from one gridview to another. It does work if I drag within the same gridview.

    I do have AllowAutoScrollRowsWhileDragging set to true.

    What could I be doing wrong?

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4125 posts

    Posted 03 Jan 2020 Link to this post

    Hello, Joe,   
    I am not sure what is the exact drag and drop implementation that you have on your end, but I would recommend you to have a look at the following help articles which are quite useful on this topic: 

    Auto-scroll behavior while dragging is relevant only when the source and target controls are the same. If you drag from one RadGridView and drop the row to another RadGridView, the auto-scrolling behavior is not expected to be executed. 

    However, you can disable the AllowAutoScrollRowsWhileDragging property for the RadGridViewDragDropService and perform the scrolling for the target grid programmatically. In the PreviewDragOver event you can check the HitTarget and increase the GridViewElement.TableElement.VScrollBar.Value of the target grid: 
            private void svc_PreviewDragOver(object sender, RadDragOverEventArgs e)
                if (e.DragInstance is GridDataRowElement)
                    e.CanDrop = e.HitTarget is GridDataRowElement ||
                                e.HitTarget is GridTableElement ||
                                e.HitTarget is GridSummaryRowElement;
                if (e.CanDrop = true)
                    GridDataRowElement hitTarget = e.HitTarget as GridDataRowElement;
                    if (hitTarget != null && hitTarget.TableElement.VisualRows.Last() == hitTarget)
                        hitTarget.GridViewElement.TableElement.VScrollBar.Value = Math.Min(hitTarget.GridViewElement.TableElement.VScrollBar.Maximum,
                            hitTarget.GridViewElement.TableElement.VScrollBar.Value + hitTarget.GridViewElement.TableElement.VScrollBar.SmallChange - 1);

    Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 


    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top