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

RowReorder and ScrollIndexIntoView

4 Answers 149 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matteo Beretta
Top achievements
Rank 1
Matteo Beretta asked on 25 Mar 2013, 10:11 AM
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);
    }
}

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Mar 2013, 11:12 AM
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.

0
Matteo Beretta
Top achievements
Rank 1
answered on 25 Mar 2013, 11:22 AM
Yes, same results.

So there isn't a solution fot this issue?
0
Massimo
Top achievements
Rank 1
answered on 10 Sep 2014, 02:28 PM
Same issue, ScrollIndexIntoViewAsync, ScrollIndexIntoView, ScrollIntoViewAsync and ScrollIntoView are not working as expected..
0
Dimitrina
Telerik team
answered on 11 Sep 2014, 07:28 AM
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.
 
Tags
GridView
Asked by
Matteo Beretta
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Matteo Beretta
Top achievements
Rank 1
Massimo
Top achievements
Rank 1
Share this question
or