Dropping into an expanded row....

5 posts, 0 answers
  1. Greg
    Greg avatar
    14 posts
    Member since:
    Jun 2008

    Posted 09 Jun 2009 Link to this post

    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.

     

     

    <Style TargetType="ctrlTelerikGridView:GridViewRow" x:Key="commonRowStyle">

     

     

     

        <Setter Property="ctrlTelerikDragDrop:RadDragAndDropManager.AllowDrop" Value="True" />

     

     

     

    </Style>

     

     

    Thanks,
    Greg
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 11 Jun 2009 Link to this post

    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:

    1 public Page() 
    2
    3     InitializeComponent(); 
    4  
    5     RadGridView1.RowLoaded += new EventHandler<Telerik.Windows.Controls.GridView.RowLoadedEventArgs>(RadGridView1_RowLoaded); 
    6
    7  
    8 void RadGridView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) 
    9
    10     Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrag(e.Row, true); 
    11     Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.SetAllowDrop(e.Row, true); 
    12

    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.
  3. DevCraft banner
  4. Greg
    Greg avatar
    14 posts
    Member since:
    Jun 2008

    Posted 12 Jun 2009 Link to this post

    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);  
            } 

     

     

     

  5. Greg
    Greg avatar
    14 posts
    Member since:
    Jun 2008

    Posted 16 Jun 2009 Link to this post

    Any other suggestion on this issue?  Do I need to submit a support ticket?
  6. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 18 Jun 2009 Link to this post

    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:

    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.
Back to Top
DevCraft banner