RowReorder and ScrollIndexIntoView

5 posts, 0 answers
  1. Matteo Beretta
    Matteo Beretta avatar
    21 posts
    Member since:
    Apr 2010

    Posted 25 Mar 2013 Link to this post

    Hello I have a grid with rows reordered I'm trying the method ScrollIndexIntoView, to make sure that the grid scroll while dragging a row.

    The first time it works, the second no.
    Post my code

    private void OnDropInfo(object sender, DragDropEventArgs e)
    {
        if (!(e.Options.Source is GridViewRow))
            return;
     
        RadGridView gridView = sender as RadGridView;
        uPlanning planningContainer = GetPlanningContainer(gridView);
        planningContainer.pTimer.Enabled = false;
     
        IList draggedItems = e.Options.Payload as IList;
        TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
        cue.DropPossibleIconTemplate = null;
        cue.DropPossibleIcon = null;
        cue.DropImpossibleIconTemplate = null;
        cue.DropImpossibleIcon = null;
     
        if (e.Options.Status == DragStatus.DropPossible)
        {
            int rowIndex = 0;
            if (draggedItems.Count > 0)
            {
                GridViewRow row = this.AssociatedObject.ItemContainerGenerator.ContainerFromItem(this.currentDropItem) as GridViewRow;
                DropPosition pos = this.GetDropPositionFromPoint(e.Options.CurrentDragPoint, row);
     
                //azzero template drag&drop
                foreach (GridViewRow gvr in gridView.ChildrenOfType<GridViewRow>())
                    gvr.BorderThickness = new Thickness(0, 0, 0, 0);
     
                rowIndex = gridView.Items.IndexOf(this.currentDropItem) + 1;
     
                #region Template drag&drop
                switch (pos.ToString())
                {
                    case ("Before"):
                        cue.DragActionContent = String.Format("Sposta prima di ");
                        if (row != null)
                        {
                            row.BorderThickness = new Thickness(0, 5, 0, 0);
                            row.BorderBrush = new SolidColorBrush(Colors.White);
                        }
                        break;
                    case ("After"):
                        cue.DragActionContent = String.Format("Sposta dopo ");
                        if (row != null)
                        {
                            row.BorderThickness = new Thickness(0, 0, 0, 5);
                            row.BorderBrush = new SolidColorBrush(Colors.White);
                        }
                        break;
                    default:
                        cue.DragActionContent = String.Format("Inserisci ");
                        break;
                }
     
                if (currentDropItem != null)
                {
                    if (currentDropItem is PROD_ORDINI)
                        cue.DragTooltipContent = (currentDropItem as PROD_ORDINI).opcliedes;
                    else
                        cue.DragTooltipContent = (currentDropItem as Cvt).cvtnumero;
     
                    cue.IsDropPossible = false;
     
                    if (gridView.Tag.ToString() == "E" && draggedItems[0] is PROD_ORDINI)
                    {
                        //se sposto all'interno dei da pianificare
                        cue.DragActionContent = null;
                        cue.IsDropPossible = true;
                    }
                    if (gridView.Tag.ToString() == "F" && draggedItems[0] is Cvt)
                    {
                        cue.DragTooltipContent = null;
                        cue.IsDropPossible = true;
                    }
                }
                #endregion
            }
            else
            {
                //azzero template drag&drop
                foreach (GridViewRow gvr in gridView.ChildrenOfType<GridViewRow>())
                    gvr.BorderThickness = new Thickness(0, 0, 0, 0);
            }
     
            gridView.ScrollIndexIntoView(rowIndex);
        }
    }
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Mar 2013 Link to this post

    Hello,

    Have you tried using the ScrollIndexIntoViewAsync method instead?

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Matteo Beretta
    Matteo Beretta avatar
    21 posts
    Member since:
    Apr 2010

    Posted 25 Mar 2013 Link to this post

    Yes, same results.

    So there isn't a solution fot this issue?
  4. Massimo
    Massimo avatar
    31 posts
    Member since:
    Apr 2013

    Posted 10 Sep 2014 Link to this post

    Same issue, ScrollIndexIntoViewAsync, ScrollIndexIntoView, ScrollIntoViewAsync and ScrollIntoView are not working as expected..
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Sep 2014 Link to this post

    Hi,

    To enable the autoscrolling functionality in our GridView control you can follow the approach shown in this online example for Silverlight. The same one is also available with the WPF Demos (search for Reorder Rows).
    For example:

    <telerik:RadGridView x:Name="RadGridView1" GroupRenderMode="Flat"
       ShowGroupPanel="False" CanUserResizeRows="True"
       ItemsSource="{Binding Customers}"
       RowStyle="{StaticResource DraggedRowStyle}"
       AllowDrop="True"
       CanUserSortColumns="False"
       IsFilteringAllowed="False"
       local:RowReorderBehavior.IsEnabled="True"
       telerik:ScrollingSettingsBehavior.IsEnabled="True"
       telerik:ScrollingSettingsBehavior.ScrollAreaPadding="30"
       telerik:ScrollingSettingsBehavior.ScrollStep="24"
       telerik:ScrollingSettingsBehavior.ScrollStepTime="00:0/>

    Does this help?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top