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

Autoscrolling in GridView while drag drop

2 Answers 316 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 19 Apr 2013, 08:58 AM
Hi all,

i have got an issue in using drag and drop functionality in combination with autoscrolling in GridView.
I must be able to select a cell in gridview and the target cell can only be made visible with scrolling up (may be the target cell is on the upper side of grid and source cell is contained in last row).
So, if I try to pick up the source cell drag and drop may be initialized and if i move mouse cursor up gridview does not autoscroll up if i come closer and closer to the also visible column headers.

Is there any way to implement it? If yes it would be very very cool if someone can post a solution for it. :)

We use RadGridview in combination with the  DragDropManage (without "and").

Regards
Martin

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 23 Apr 2013, 08:57 AM
Hi Martin,

Have you implemented any custom logic to "Autoscroll" when you drag, or do you expect this to be done out of the box? 
If that is the case you can look into this example to see how this can be done.

<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:00:00.05">

Hope this helps!  Regards,
Nikolay Vasilev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mark
Top achievements
Rank 1
answered on 31 Jul 2013, 11:29 AM
Hi all,

i had the same issue as Martin and use also the ScrollingSettingBehaviour.

Now I have the problem, that the dragged item a GridViewCell lose his DataContext in the moment,
that the cell is no longer visible because of scrolling.

GridView:
<telerik:RadGridView x:Name="Grid"
              Grid.Row="0"
              AutoGenerateColumns="True"
              AutoGeneratingColumn="AutoGeneratingColumn"
              CanUserDeleteRows="False"
              CanUserFreezeColumns="False"
              CanUserInsertRows="False"
              CanUserResizeColumns="True"
              CanUserSortColumns="False"
              ColumnWidth="*"
              GridLinesVisibility="None"
              IsFilteringAllowed="False"
              IsReadOnly="True"
              ItemsSource="{Binding AllRows}"
              MouseDoubleClick="OnMouseDoubleClick"
              RowIndicatorVisibility="Collapsed"
              SelectionUnit="Cell"
              ToolTipService.IsEnabled="True"
              ShowGroupPanel="False"
              telerik:ScrollingSettingsBehavior.IsEnabled="True"
              telerik:ScrollingSettingsBehavior.ScrollAreaPadding="30"
              telerik:ScrollingSettingsBehavior.ScrollStep="24"
              telerik:ScrollingSettingsBehavior.ScrollStepTime="00:00:00.05"/>

Behaviour:
    <Style x:Key="CellStyle"
           BasedOn="{StaticResource {x:Type telerik:GridViewCell}}"
           TargetType="telerik:GridViewCell">
...
<Setter Property="behavior:DragDropBehavior.DragValidationCommand"
      Value="{Binding Path=DataContext.DragValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
<Setter Property="behavior:DragDropBehavior.DropValidationCommand"
      Value="{Binding Path=DataContext.DropValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
<Setter Property="behavior:DragDropBehavior.DragOverValidationCommand"
      Value="{Binding Path=DataContext.DragOverValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
<Setter Property="behavior:DragDropBehavior.DropCompletedCommand"
      Value="{Binding Path=DataContext.DropCompletedCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />

Has anybody an idea where I made my mistake?
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Nick
Telerik team
Mark
Top achievements
Rank 1
Share this question
or