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!!
7 Answers, 1 is accepted
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

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!
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

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
>
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

Hi Stefan,
I have a similar problem like Wang. I am developing a control which contains a GridView. Some of the items can have sub items which are assigned to another GridView which is the HierarchyChildTemplate of the main GridView.
How can I implement a drag and drop functionality between the main GridView and the child GridView and vice versa.
Thanks.
Beste regards
Peter
I answered your question in the other forum thread that you have opened: DragDrop between GridView and child GridView in HierachyChildTemplate.
Regards,
Vladimir Stoyanov
Progress Telerik