RadGridView with HierarchyChildTemplate

9 posts, 0 answers
  1. Anurag
    Anurag avatar
    4 posts
    Member since:
    Feb 2011

    Posted 20 Feb 2011 Link to this post

    Hi,

    I am new to Telerik RadGridView and facing issues when using Telerik RadGridView with HierarchyChildTemplate.Here is the scenario I am trying to achieve -

    1. I have a RadGridView with only 4 columns
    2. In the same RadGridView I have HierarchyChildTemplate
    3. Within HierarchyChildTemplate I have DataTemplate with RadTabControls and 4 RadTabItems
    4. Every RadTabItem has TextBlocks,TextBoxes and ComboBoxes.
    5. I have added the RadGridView table definitions and childdefinitions,so I get data populated in the radgrid rows and all controls
        in the RadTabItems gets automatically populated.

    6. I have also added the Edit Save and Cancel buttons outside the HierarchyChildTemplate to have a common functionality applied to all RadTab items.

    The issue is that 
        - I am not able to get the values from the controls that I have placed in RadTabItems although all the controls have values.
        - I am also not able to get the CurrentItem of the RadGridView.It always gives me first item of the RadGridView even if I am in
          other Row.

    I need help on this.

    Many Thanks
    Anurag
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 22 Feb 2011 Link to this post

    Hi Anurag,

    Depending on your particular settings, you may get the values displayed in the DataTemplate by the corresponding item of the grid. Furthermore, in case you find it more appropriate, you may achieve the same behavior by using the RowDetailsTemplate instead. 
    As far as your second requirement is concerned, you may try to set the IsSynchronizedWithCurrentItem property of the grid to "True".

     

    Kind regards,
    Maya
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Anurag
    Anurag avatar
    4 posts
    Member since:
    Feb 2011

    Posted 23 Feb 2011 Link to this post

    Hi,

    Based on your suggestion I am implementing the scenario. Now I have a requirement to load the Row as soon as the userclicks
    the row, a kind of load on demand.Please can you share some example to achieve this.

    <

     

     

    Grid x:Name="LayoutRoot">

     

     

     

     

    <telerikGridView:RadGridView x:Name="gridViewEmployeeList" GridLinesVisibility="Horizontal"

     

     

     

     

    AutoGenerateColumns="False" IsBusy="False" IsReadOnly="True" RowIndicatorVisibility="Collapsed" RowDetailsVisibilityMode="VisibleWhenSelected">

     

     

     

     

    <telerikGridView:RadGridView.Columns>

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Emp Number" DataMemberBinding="{Binding EmpNumber}" HeaderTextAlignment="Center" Width="Auto" />

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Emp Name" DataMemberBinding="{Binding Name}" HeaderTextAlignment="Center" Width="Auto" />

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Location" DataMemberBinding="{Binding Location}" HeaderTextAlignment="Center" Width="Auto" />

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Contact No" DataMemberBinding="{Binding MobileNumber}" TextWrapping="Wrap" HeaderTextAlignment="Center" Width="Auto"/>

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Photo" DataMemberBinding="{Binding Photo.Byte}" TextWrapping="Wrap" HeaderTextAlignment="Center" Width="Auto"/>

     

     

     

     

    <telerikGridView:GridViewDataColumn IsVisible="False" Header="Emp ID" DataMemberBinding="{Binding Empid}" TextWrapping="Wrap" HeaderTextAlignment="Center" Width="Auto"/>

     

     

     

     

    </telerikGridView:RadGridView.Columns>

     

     

     

     

    <telerikGridView:RadGridView.RowDetailsTemplate>

     

     

     

     

    <DataTemplate>

     

     

     

     

    <telerikNavigation:RadTabControl.....

     

     

     

    <telerikNavigation:RadTabItem ....

     

     

     

    <telerikNavigation:RadTabItem ....

     

     

     

    </DataTemplate>

     

     

     

     

    </telerikGridView:RadGridView.RowDetailsTemplate>

     

     

     

     

    </telerikGridView:RadGridView>

     

     

     

     

    </Grid>

    Many Thanks
    Anurag

     

  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 23 Feb 2011 Link to this post

    Hello Anurag,

    Generally, the RowDetails will be loaded on demand once the user clicks on the corresponding item. However, in case you need to implement some additional logic, you may use either LoadingRowDetails or RowDetailsVisibilityChanged events.You may take a look at our online documentation for further reference.
     

    Greetings,
    Maya
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Anurag
    Anurag avatar
    4 posts
    Member since:
    Feb 2011

    Posted 25 Feb 2011 Link to this post

    Hi,

    Thanks.

    I have managed it.Now I am using RowDetailsTemplate and used SelectionChanged event of the grid and hooked
    this event. In the SelectionChanged  event handler of the RadGridView I am using SelectedItem property to get the selected
    Row and applied Custom Logic of Edit/Save/Cancel on it.

    Many Thanks
    Anurag
  6. Ushashree
    Ushashree avatar
    2 posts
    Member since:
    Dec 2017

    Posted 28 Dec 2017 Link to this post

    Hi We are using Telerik version 2010.2.0924.35 in one of our WPF application.

    We are using HierarchyChildTemplate which binds data from backend. Which is not refreshing for the first time. Here are details steps

    1. HierarchyChildTemplate refreshes when user clicks on + (Expand button) for the first time

    2. Data is being retrieved from DB but its not binding to the HierarchyChildTemplate RadGridView

    3. When we close the expand and try to reopen again we are seeing the data. this issue is happening for the first time expand only.

    Sample Xaml code

    <telerik:RadGridView.HierarchyChildTemplate>
    <DataTemplate>
    <telerik:RadGridView Height="Auto" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Top"
    AutoGenerateColumns="False" ItemsSource="{Binding ExceptionOverride, Mode=TwoWay}"
    ShowGroupPanel="False" SelectionUnit="Cell"
    ClipboardCopyMode="Default" SelectionMode="Extended" CanUserSortColumns="True" >
    <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=HsdAppNumber.DisplayValue}" Header="Contract" UniqueName="Contract" IsReadOnly="True" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=State.DisplayValue}" Header="State" UniqueName="State" IsReadOnly="True" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=County.DisplayValue}" Header="County" UniqueName="County" IsReadOnly="True" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SpecialtyDescription.DisplayValue}" Header="HSD Specialty" UniqueName="SpecialtyName" IsReadOnly="True" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Reason.DisplayValue}" Header="Reason For Override" UniqueName="Reason" IsReadOnly="True" />
    <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Path=FlgEligible.DisplayValue}" UniqueName="ExceptionOverride" Header="Delete" EditTriggers="CellClick" AutoSelectOnEdit="True">
    <telerik:GridViewCheckBoxColumn.CellStyle>
    <Style TargetType="telerik:GridViewCell"></Style>
    </telerik:GridViewCheckBoxColumn.CellStyle>
    </telerik:GridViewCheckBoxColumn>
    </telerik:RadGridView.Columns>
    </telerik:RadGridView>
    </DataTemplate>
    </telerik:RadGridView.HierarchyChildTemplate>

     

    Code Behind for RowIsExpandedChanged event

    var childGridViewList = row.ChildrenOfType<RadGridView>();
    if (!childGridViewList.IsNullOrEmpty() && null != childGridViewList.FirstOrDefault())
    {
    var childExceptionOverrideGridview = childGridViewList.FirstOrDefault();
    var exceptionOverride = this.viewModel.GetExceptionOverride(availableProviderDataItem.Id.Current);
    //Clearing the ItemSource of child grid, re-assigning the ItemSource and Rebind the grid to fix UI refresh issue #335100
    childExceptionOverrideGridview.ItemsSource = null;
    childExceptionOverrideGridview.ItemsSource = exceptionOverride;
    availableProviderDataItem.ExceptionOverride = exceptionOverride;
    childExceptionOverrideGridview.Rebind();
    }

     

  7. Stefan
    Admin
    Stefan avatar
    959 posts

    Posted 02 Jan Link to this post

    Hello Ushashree,

    Though I cannot confirm the exact cause for this behavior, my best guess is that it is due to a timing issue. so, instead of using the RowIsExpandedChanged event, may I ask you to try using the RowIsExpandedChanging one? It is raised when the row is about to be expanded, whereas the first one is raised when the row is already expanded. Does this solve the issue you are experiencing? If this does not help, can you please try updating your assemblies to the newest possible version? Is the problem reproduced with the newer version as well?

    Regards,
    Stefan
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  8. Ushashree
    Ushashree avatar
    2 posts
    Member since:
    Dec 2017

    Posted 03 Jan in reply to Stefan Link to this post

    Thank Stefan for your reply.  We have tried using “RowIsExpandedChanging” event as you mentioned, but that did not work as expected. We are still experiencing the same issue. We will try updating the new assemblies but that licensed to be used at client's location where this is being used. In the meantime, could you please let us know if there are any workaround to solve the issue?
  9. Stefan
    Admin
    Stefan avatar
    959 posts

    Posted 04 Jan Link to this post

    Hi Ushashree,

    Thanks for the update.

    After the additional investigation I made, it seems that this might turn to be a timing issue. My best guess is that it is due to the hierarchical RadGridView being accessed directly through the VisualTree. Note, that such an approach is generally not recommended when using RadGridView. As previously mentioned in this thread, you can try using the RowDetails mechanism instead. Through it you should be able to achieve such on-demand loading of the hierarchical data through the events provided by the control. You may find the Find a Control in RowDetailsTemplate topic useful for achieving your goal.

    Hope this helps.

    Regards,
    Stefan
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top