Drag & drop and Hierarchy

6 posts, 0 answers
  1. Wang
    Wang avatar
    42 posts
    Member since:
    Oct 2011

    Posted 19 Jan Link to this post

    Hello!

    I have two problem,

    1:

    Is there  some method to  Drag & drop  only in parent gridview self and Hierarchy gridview self?

    for eg. 

    p1

         sub1

         sub2

         sub3

    p2

        sub4

        sub5

        sub6

    p3

        sub7
        sub8
        sub9

     

    can we Drag & drop only between p1,p2,p3 for order

    and Drag & drop only between sub1 sub2 sub3…

     

     2.

    Is there  some method to  Drag & drop  only in parent gridview self and gridview in RowDetailsTemplate self?

     

    It is a big forever If you can provide a sample! thanks a lot!!

  2. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 21 Jan Link to this post

    Hello Wang,

    In general, this requirement can be achieved by setting the AllowDrop property of a given GridViewRow to "False". I suggest you taking a look at the Drag and Drop within RadGridView help topic. If you review the OnRowDragOver event handler method, you will notice that the sender object is the currently dragged row. So, you can implement custom logic depending on whether a given row is an item of the parent collection or the child one, and set its AllowDrop property as per your requirements.

    Hope this helps.

    All the best,
    Stefan X1
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Wang
    Wang avatar
    42 posts
    Member since:
    Oct 2011

    Posted 22 Jan in reply to Stefan X1 Link to this post

    Hello Stefan X1 ,

    I looked at the Drag and Drop within RadGridView topic and it worked well in one GridView,and try to setting the AllowDrop property in OnRowDragOver event handler method in Hierarchy gridview by HierarchyChildTemplate,but it did not work fine, may be I set it to a wrong way,can you provide a sample? thanks a lot!!

    best wishes!

  5. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 25 Jan Link to this post

    Hello Wang,

    Can you please share some details on the difficulties you are experiencing at your end? Basically, you need to set the AllowDrop property of the hierarchical grid to "True" and apply a Style targeting its GridViewRow elements that sets the AllowDrag property to "True". You need to also ensure, that you have enabled the RowReorderBehavior for the hierarchical grid, as demonstrated in the article I referred to in my previous post.

    You can also check out the relevant SDK Example using the SDK Samples Browser.

    Best Regards,
    Stefan X1
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Wang
    Wang avatar
    42 posts
    Member since:
    Oct 2011

    Posted 31 Jan Link to this post

    Hello Stefan X1,

    I tried to set the AllowDrop property and set row AllowDrop property in OnRowDragOver event,

    there's no DropPositionFeedback  when I DragOver a child to anther child, but it can be shown when I drag a parent to anther parent.

    here is my xaml code:

    <telerik:RadGridView x:Name="StageGrid" GroupRenderMode="Flat"
    SelectionMode="Extended"
    CanUserFreezeColumns="False" ColumnWidth="*"
    ItemsSource="{Binding StageCollection}"
    GridLinesVisibility="None" RowIndicatorVisibility="Collapsed"
    AutoGenerateColumns="False" IsFilteringAllowed="False"
    ShowGroupPanel="False" SelectionChanged="StageGrid_SelectionChanged"
    AllowDrop="True" behavior:RowReorderBehavior.IsEnabled="True">
                <telerik:RadGridView.Resources>
                    <DataTemplate x:Key="DraggedItemTemplate">
                        <StackPanel>
                            <TextBlock Text="{Binding CurrentDraggedItem.Name}" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                    <converter:IntegerToBooleanConverter x:Key="integerToBooleanConverter" />
                </telerik:RadGridView.Resources>
                <telerik:RadGridView.RowStyle>
                    <Style TargetType="telerik:GridViewRow">
                        <Setter Property="telerik:DragDropManager.AllowDrag"
                        Value="True" />
                        <Setter Property="telerik:DragDropManager.TouchDragTrigger"
                        Value="TapAndHold"/>
                        <Setter Property="IsExpandable" Value="True"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Converter={StaticResource integerToBooleanConverter}, Path=SubList.Count}" Value="False">
                                <Setter Property="IsExpandable" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </telerik:RadGridView.RowStyle>
                <telerik:RadGridView.Columns>
                    <custom:NumberColumn Header="Nummber" Width="auto" ></custom:NumberColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition />
                </telerik:RadGridView.ChildTableDefinitions>
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate>
                        <telerik:RadGridView x:Name="SectionGrid" GroupRenderMode="Flat"
     GridLinesVisibility="None"                                  CanUserFreezeColumns="False"                                        AutoGenerateColumns="False"                                     ShowGroupPanel="False"  IsFilteringAllowed="False" ItemsSource="{Binding SubList}" AllowDrop="True"
                behavior:RowReorderBehavior.IsEnabled="True">
                            <telerik:RadGridView.Resources>
                                <DataTemplate x:Key="DraggedItemTemplate">
                                    <StackPanel>
                                        <TextBlock Text="{Binding CurrentDraggedItem.Name}" FontWeight="Bold" />
                                    </StackPanel>
                                </DataTemplate>
                                <converter:IntegerToBooleanConverter x:Key="integerToBooleanConverter"/>
                            </telerik:RadGridView.Resources>
                            <telerik:RadGridView.RowStyle>
                                <Style TargetType="telerik:GridViewRow">
                                    <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" />
                                    <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
                                    <Setter Property="IsExpandable" Value="True"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Converter={StaticResource integerToBooleanConverter}, Path=SubList.Count}" Value="False">
                                            <Setter Property="IsExpandable" Value="False"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </telerik:RadGridView.RowStyle>
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
                                                Header="Name" />
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Size}"
                                                Header="Size(mm)" />
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding SumSize}"
                                                Header="SumSize(mm)" />
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate>
            </telerik:RadGridView>

  7. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 03 Feb Link to this post

    Hi Wang,

    Can you please clarify whether you are referring to the symbol appearing over a given element, to which the drop operation is disabled? If this is the case, please note, that if the AllowDrop property is correctly set to a given GridViewRow, this symbol would appear automatically. Basically, within the DragOver event handler, you can use the DataContext of a given GridViewRow to determine whether the item is from the child or the parent collection, thus set the AllowDrop property accordingly.

    Best Regards,
    Stefan X1
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready