I have a datagrid with 5 levels of child grids inside of it. I am using the HierarchyChildTemplate property to setup my grid in XAML. I then subscribe to the PreviewDataRecordCreate to create the child relations and assign its datasource.
On the OnDragInfo event, I check if the DataContext of the target GridViewRow contains a certain value that will make the grid expandable, and if it does I prompt the user accordingly.
The problem I run into with dropping onto it is that if I don't set the ExpandableRowStyle property on the grid, the ExpandableRow is not being registered in the OnDragInfo event as the Destination. The Destination seems to be the last valid "droppable" row the mouse hovered over.
If I do set the ExpandableRowStyle property, I can validate as necessary. However, once I expand the row, I want to drop onto rows in the child grid. But, the parent expanded row is being registerd as the target.
Suggestion on how I can incorporate having the ExpandedRow show up as a target if needed, but also have it children grid rows show up as targets?
Below is the XAML I am using for row styling. I am using the same style for both the RowStyle property and the ExpandableRowStyle property.
Thanks,
Greg
On the OnDragInfo event, I check if the DataContext of the target GridViewRow contains a certain value that will make the grid expandable, and if it does I prompt the user accordingly.
The problem I run into with dropping onto it is that if I don't set the ExpandableRowStyle property on the grid, the ExpandableRow is not being registered in the OnDragInfo event as the Destination. The Destination seems to be the last valid "droppable" row the mouse hovered over.
If I do set the ExpandableRowStyle property, I can validate as necessary. However, once I expand the row, I want to drop onto rows in the child grid. But, the parent expanded row is being registerd as the target.
Suggestion on how I can incorporate having the ExpandedRow show up as a target if needed, but also have it children grid rows show up as targets?
Below is the XAML I am using for row styling. I am using the same style for both the RowStyle property and the ExpandableRowStyle property.
<Style TargetType="ctrlTelerikGridView:GridViewRow" x:Key="commonRowStyle">
<Setter Property="ctrlTelerikDragDrop:RadDragAndDropManager.AllowDrop" Value="True" />
</Style>
Thanks,
Greg
4 Answers, 1 is accepted
0
Hi Greg,
What I would suggest is to allow drag & drop in the code-behind.
In the event handler of RowLoaded you can do the following:
Give it a try and if you encounter any problems let us know.
Kind regards,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
What I would suggest is to allow drag & drop in the code-behind.
In the event handler of RowLoaded you can do the following:
public Page() | |
{ | |
InitializeComponent(); | |
RadGridView1.RowLoaded += new EventHandler<Telerik.Windows.Controls.GridView.RowLoadedEventArgs>(RadGridView1_RowLoaded); | |
} | |
void RadGridView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) | |
{ | |
Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrag(e.Row, true); | |
Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrop(e.Row, true); | |
} |
Give it a try and if you encounter any problems let us know.
Kind regards,
Kiril Stanoev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Greg
Top achievements
Rank 1
answered on 12 Jun 2009, 03:07 PM
I am still having the same issues. The only way I can get this to semi-work is to the following:
XAML:
<ctrlTelerikControls:RadGridView x:Name="TargetsGrid" CanUserReorderColumns="False" |
CanUserFreezeColumns="False" CanUserResizeColumns="False" ShowGroupPanel="False" HorizontalAlignment="Left" |
IsFilteringAllowed="False" AutoGenerateColumns="False" RowIndicatorVisibility="Visible" |
ColumnsWidthMode="Fill" MultipleSelect="False" ScrollMode="RealTime" Background="White" RowLoaded="TargetsGrid_RowLoaded"> |
<ctrlTelerikControls:RadGridView.Columns> |
<ctrlTelerikControls:GridViewDataColumn DataMemberPath="TargetFieldName" IsReadOnly="True"/> |
<ctrlTelerikControls:GridViewDataColumn DataMemberPath="FieldTypeName" IsReadOnly="True"/> |
<ctrlTelerikControls:GridViewColumn CellStyle="{StaticResource ValuesStyle}" /> |
<ctrlTelerikControls:GridViewColumn CellStyle="{StaticResource TrustLevelStyle}" Width="65"/> |
<ctrlTelerikControls:GridViewColumn CellStyle="{StaticResource FieldPopulationStyle}" Width="100"/> |
<ctrlTelerikControls:GridViewDataColumn DataMemberPath="ElementId" IsVisible="False"/> |
</ctrlTelerikControls:RadGridView.Columns> |
<ctrlTelerikControls:RadGridView.HierarchyChildTemplate> |
<DataTemplate> |
<StackPanel Background="White"> |
<ctrlTelerikControls:RadGridView CanUserReorderColumns="False" |
CanUserFreezeColumns="False" CanUserResizeColumns="False" ShowGroupPanel="False" HorizontalAlignment="Left" |
IsFilteringAllowed="False" AutoGenerateColumns="False" RowIndicatorVisibility="Visible" |
MultipleSelect="False" ScrollMode="RealTime" Background="White" RowLoaded="TargetsGrid_RowLoaded"> |
</ctrlTelerikControls:RadGridView> |
</StackPanel> |
</DataTemplate> |
</ctrlTelerikControls:RadGridView.HierarchyChildTemplate> |
</ctrlTelerikControls:RadGridView> |
Code behind for row loaded:
private void TargetsGrid_RowLoaded(object sender, RowLoadedEventArgs e) |
{ |
if (e.Row is GridViewExpandableRow) |
{ |
return; |
} |
RadDragAndDropManager.SetAllowDrop(e.Row, true); |
} |
0
Greg
Top achievements
Rank 1
answered on 16 Jun 2009, 02:56 PM
Any other suggestion on this issue? Do I need to submit a support ticket?
0
Hello Greg Case,
First excuse me for the delay in communication.
I have prapared a sample project that demonstrates that the GridViewExpandableRow can be registered by the drag and drop manager.
There are two important configurations that should be made before the manager can register the GridViewExpandableRow for drag and GridViewRow for drag and drop.
First you should allow the drag and drop like this:
The second important thing is to set the e.QueryResult = true in the OnDropQuery and OnDragQuery query events whenever that is applicable.
After that you should get both row types as Destination in the DragInfo events.
Hope this helps.
If you have more questions do not hesitate to write.
Sincerely yours,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
First excuse me for the delay in communication.
I have prapared a sample project that demonstrates that the GridViewExpandableRow can be registered by the drag and drop manager.
There are two important configurations that should be made before the manager can register the GridViewExpandableRow for drag and GridViewRow for drag and drop.
First you should allow the drag and drop like this:
void radGridViewCustomHierarchy_RowLoaded(object sender, RowLoadedEventArgs e) |
{ |
if (e.Row is GridViewExpandableRow) |
{ |
Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrag(e.Row, true); |
} |
if (e.Row is GridViewRow) |
{ |
Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrag(e.Row, true); |
Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrop(e.Row, true); |
} |
} |
The second important thing is to set the e.QueryResult = true in the OnDropQuery and OnDragQuery query events whenever that is applicable.
After that you should get both row types as Destination in the DragInfo events.
Hope this helps.
If you have more questions do not hesitate to write.
Sincerely yours,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.