Nested HierarchyChildTemplates

17 posts, 0 answers
  1. Thomas Garp
    Thomas Garp avatar
    11 posts
    Member since:
    Aug 2008

    Posted 11 Aug 2009 Link to this post

    Hi Support
    I am trying to accomplish a scenario, where i have 3 levels of radgrids in a custom hierarchy
    I want to be able to style the child grids, therefore I have used nested HierarchyChildTemplates inside the master table. Like this:
    <telerikGridView:RadGridView   
                            x:Name="MasterGridView"   
                            CanUserInsertRows="False"   
                            AutoGenerateColumns="False"   
                            CanUserFreezeColumns="False"   
                            CanUserReorderColumns="False" 
                            Height="600" Width="Auto" Background="#FFC6C6C6" 
            > 
     
                              
     
                            <telerikGridView:RadGridView.Columns> 
                                  
                                <telerikGridView:GridViewDataColumn HeaderText="Col1" DataMemberBinding="{Binding Path=CustomerShortDisplayType}" IsFilterable="True" IsGroupable="True" IsSortable="True"  Width="55" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" /> 
                                <telerikGridView:GridViewDataColumn HeaderText="Col2" DataMemberBinding="{Binding Path=CustomerCurrency}" IsFilterable="True" IsGroupable="True" IsReadOnly="True" Width="55" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" /> 
                                  
     
                            </telerikGridView:RadGridView.Columns> 
                              
                            <telerikGridView:RadGridView.HierarchyChildTemplate> 
                                 
                                    <DataTemplate > 
                                    <StackPanel DataContext="{x:Null}">  
                                          
     
                                       <telerikGridView:RadGridView   
                                                        x:Name="InnerGridView" 
                                                        CanUserInsertRows="False"   
                                                        AutoGenerateColumns="False"   
                                                        CanUserFreezeColumns="False"   
                                                        CanUserReorderColumns="False" 
                                                         Width="Auto" Background="#FFC6C6C6" 
                                                       ItemsSource="{Binding ChildCustomers}" 
                                                        Loaded="ChildRadGridView_Loaded" 
                                                        ShowColumnHeaders="False"   
                                                        ShowGroupPanel="False" Style="{StaticResource childGridviewStyle}" 
                                                          
                                        > 
                                                                                                                  
                                              
                                            <telerikGridView:RadGridView.Columns> 
                                                 
                                                <telerikGridView:GridViewDataColumn  HeaderText="CustomerName" DataMemberBinding="{Binding Path=CustomerShortDisplayType}" IsFilterable="True" IsGroupable="True" IsSortable="True"  Width="55" CellStyle="{StaticResource ChildGridDataCellStyle1}" /> 
                                                <telerikGridView:GridViewDataColumn HeaderText="Currency" DataMemberBinding="{Binding Path=CustomerCurrency}" IsFilterable="True" IsGroupable="True" IsReadOnly="True" Width="55" CellStyle="{StaticResource ChildGridDataCellStyle1}" /> 
                                                <telerikGridView:GridViewDataColumn HeaderText="Manager" DataMemberBinding="{Binding Path=Manager}"  IsGroupable="True" IsReadOnly="True" Width="55" CellStyle="{StaticResource ChildGridDataCellStyle1}" /> 
                                                  
     
                                            </telerikGridView:RadGridView.Columns> 
                                           
                                         <telerikGridView:RadGridView.HierarchyChildTemplate  > 
     
                                                <DataTemplate > 
                                                    <StackPanel DataContext="{x:Null}">  
                                                        <telerikGridView:RadGridView CanUserInsertRows="False"   
                                                                  Margin="95,0,0,0" 
                                                                    AutoGenerateColumns="False"   
                                                                    CanUserFreezeColumns="False"   
                                                                    ShowGroupPanel="False" 
                                                                   ItemsSource="{Binding CustomerValues}" 
                                                                    ShowColumnHeaders="False"   
                                                                    Style="{StaticResource childGridviewStyle}" 
                                                                    CanUserReorderColumns="False" 
                                                                    Loaded="ChildRadGridView_Loaded" 
                                                        > 
     
                                                            <telerikGridView:RadGridView.Columns> 
                                                                <telerikGridView:GridViewDataColumn HeaderText="Type" DataMemberBinding="{Binding Path=Customer.ShortDisplayCustomerType}"  IsSortable="False" IsFilterable="False" IsGroupable="False" IsReadOnly="True" Width="55" CellStyle="{StaticResource ChildGridDataCellStyle}"  /> 
                                                                <telerikGridView:GridViewDataColumn HeaderText="Cur." DataMemberBinding="{Binding Path=CurrencyName}" IsSortable="False" IsFilterable="False" IsGroupable="False" IsReadOnly="True" Width="55" CellStyle="{StaticResource ChildGridDataCellStyle}" /> 
                                                                <telerikGridView:GridViewDataColumn HeaderText="Mgr." DataMemberBinding="{Binding Path=Customer.Manager}"  IsSortable="False" IsFilterable="False" IsGroupable="False" IsReadOnly="True" Width="55" CellStyle="{StaticResource ChildGridDataCellStyle}"/>  
                                                                
     
                                                            </telerikGridView:RadGridView.Columns> 
     
     
                                                        </telerikGridView:RadGridView> 
     
                                                         
                                                    </StackPanel> 
     
                                                </DataTemplate> 
     
     
                                            </telerikGridView:RadGridView.HierarchyChildTemplate> 
     
                                        </telerikGridView:RadGridView> 
                                    </StackPanel> 
                                      
                                </DataTemplate> 
                                  
     
                            </telerikGridView:RadGridView.HierarchyChildTemplate> 
                                                </telerikGridView:RadGridView> 

    Notice ive used the pattern as described in the post here.

    In the .cs file i have hooked up to the PreviewDataRecordCreate event of the mastergrid:
    MasterGridView.TableDefinition.PreviewDataRecordCreate += new EventHandler<DataRecordCreateEventArgs>(TableDefinition_PreviewDataRecordCreate); 

    And in the eventhandler, i fill the tabledefinitions into the child-templates:
        void TableDefinition_PreviewDataRecordCreate(object sender, DataRecordCreateEventArgs e)  
            {  
                var childCustomerDefinition = new GridViewTableDefinition();  
                childCustomerDefinition.Relation = new PropertyRelation("ChildCustomers");  
                childCustomerDefinition.AutoGenerateFieldDescriptors = true;  
                e.IsExpandableRecord = true;  
                  
     
                var childM2MValues = new GridViewTableDefinition();  
                childM2MValues.Relation = new PropertyRelation("CustomerValues");  
                childM2MValues.AutoGenerateFieldDescriptors = false;  
     
                childCustomerDefinition.ChildTableDefinitions.Add(childM2MValues);  
     
                e.ChildTableDefinitions.Add(childCustomerDefinition);  
     
            } 

    The bottom line of this setup is: Only the 1.st level can exand, and the 2.nd level is filled with data, but cannot expand any further (i.e. the 3.rd level is never displayed /filled with data)
    Is it not at all possible to use nested Hierarchytemplates?

    Regards, Thomas Garp

  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 12 Aug 2009 Link to this post

    Hello Thomas Garp,

    Yes, this is possible. The <StackPanel DataContext="{x:Null}"> is a legacy hack that you need to remove. It was used in the past to overcome a shortcoming, but now everything should work without it in a more straightforward way.

    I have prepared a small sample project that demonstrates how to do this. My setup is the following: We have football clubs, which have players, which have games.

    Clubs
       Players
          Games

    And here is how to do it:

    <UserControl x:Class="TicketID_234244_NestedHierarchyChildTemplates.MainPage" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
        <Grid> 
            <telerik:RadGridView Name="clubsGrid"  
                                 AutoGenerateColumns="False" 
                                 ColumnsWidthMode="Auto"
                <telerik:RadGridView.Columns> 
                    <telerik:GridViewDataColumn  
                        Header="Name"  
                        DataMemberBinding="{Binding Name}"/> 
                    <telerik:GridViewDataColumn  
                        Header="Est."  
                        DataMemberBinding="{Binding Established}" 
                        DataFormatString="{}{0:yyyy}"/> 
                    <telerik:GridViewDataColumn  
                        Header="Stadium" 
                        DataMemberBinding="{Binding StadiumCapacity}"  
                        DataFormatString="{}{0:N0}"/> 
                </telerik:RadGridView.Columns> 
                <telerik:RadGridView.HierarchyChildTemplate> 
                    <DataTemplate> 
                        <telerik:RadGridView 
                            Name="playersGrid"  
                            ShowGroupPanel="False" 
                            AutoGenerateColumns="False" 
                            ColumnsWidthMode="Auto"
                            <telerik:RadGridView.Columns> 
                                <telerik:GridViewDataColumn  
                                    Header="Name"  
                                    DataMemberBinding="{Binding Name}"/> 
                                <telerik:GridViewDataColumn  
                                    Header="Number"  
                                    DataMemberBinding="{Binding Number}"/> 
                                <telerik:GridViewDataColumn  
                                    Header="Position"  
                                    DataMemberBinding="{Binding Position}"/> 
                                <telerik:GridViewDataColumn  
                                    Header="Country"  
                                    DataMemberBinding="{Binding Country}"/> 
                            </telerik:RadGridView.Columns> 
                            <telerik:RadGridView.HierarchyChildTemplate> 
                                <DataTemplate> 
                                    <telerik:RadGridView  
                                        Name="gamesGrid"  
                                        ShowGroupPanel="False" 
                                        ColumnsWidthMode="Auto"
                                    </telerik:RadGridView> 
                                </DataTemplate> 
                            </telerik:RadGridView.HierarchyChildTemplate> 
                        </telerik:RadGridView> 
                    </DataTemplate> 
                </telerik:RadGridView.HierarchyChildTemplate> 
            </telerik:RadGridView> 
        </Grid> 
    </UserControl> 
     

    And the code-behind is:

    using System.Windows.Controls; 
    using Telerik.Windows.Controls; 
    using Telerik.Windows.Data; 
     
    namespace TicketID_234244_NestedHierarchyChildTemplates 
        public partial class MainPage : UserControl 
        { 
            public MainPage() 
            { 
                InitializeComponent(); 
                 
                GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition(); 
                playersTableDefinition.Relation = new PropertyRelation("Players"); 
                this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition); 
     
                GridViewTableDefinition gamesTableDefinition = new GridViewTableDefinition(); 
                gamesTableDefinition.Relation = new PropertyRelation("Games"); 
                playersTableDefinition.ChildTableDefinitions.Add(gamesTableDefinition); 
     
                this.clubsGrid.ItemsSource = Club.GetClubs(); 
            } 
        } 

    You will need to update to the latest internal build, which you can find in your Client.Net.

    Please, examine the attached sample project and let me know if you have any other questions.

    Greetings,
    Ross
    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. Chris Williams
    Chris Williams avatar
    63 posts
    Member since:
    Oct 2004

    Posted 02 Sep 2009 Link to this post

    In your Club.GetClubs() method, you build your IEnumberable<Club> right there in the same method, so there's no issue on timing when you send back your data to the ClubsGrid. However, all of my data comes in via web services, which I will have to call based on whatever row is opened.

    What issues will I run in to when I'm using a web service to return my club list, and since it's async, it may take a few seconds to return data... Do I have to get all of my data before I return it in the ItemSource property?  Or do I just specify the method, and it gets filled in whenever it eventually gets here?

    Chris
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 03 Sep 2009 Link to this post

    Hello Chris Williams,

    Since your data are populated asynchronously you do not need the grid asynchronous load mode. If you want to show the grid loading indicator you can use IsBusy property of the grid.

    The other option is to tell the grid load its data asynchronously. To learn how, please see this help topic and this example.

    Please, let me know if you have any other questions.

    Best wishes,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Chris Williams
    Chris Williams avatar
    63 posts
    Member since:
    Oct 2004

    Posted 03 Sep 2009 Link to this post

    Ross,

    Thanks for your reply, but I don't think I explained my question well.

    I'm quite familiar with how to load the main grid data asynchronously... that's what I'm already doing.

    But, from everything I've read on hierchical grids, you have to supply *all* of the data for *all* of the tables during the initial data bind.  I've looked at the four samples.  And to me, that's not going to be very performant in my app.

    For example, here's your code:

    public MainPage()    
            {    
                InitializeComponent();    
                    
                GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition();    
                playersTableDefinition.Relation = new PropertyRelation("Players");    
                this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition);    
        
                GridViewTableDefinition gamesTableDefinition = new GridViewTableDefinition();    
                gamesTableDefinition.Relation = new PropertyRelation("Games");    
                playersTableDefinition.ChildTableDefinitions.Add(gamesTableDefinition);    
        
                this.clubsGrid.ItemsSource = Club.GetClubs();    
            }    
     

    I see where you define the relation properties (Players, Games). By the time you call Club.GetClubs, all of the data is known to the grid.  For example, four clubs, four players on a club, varying number of games per player, etc.  But what if you had a marked larger number of players, clubs, games, etc.?

    In my case, my main table may have up to 5000 rows in it, not a lot.  But to build up the secondary level of the hierarchy, I have to execute a specific stored procedure based on the ID and some other values... if I built it up before hand, I'd have to make up to 5000 additional calls to the DB, even if the user decided they didn't want to see any sub-details.

    In asp.net, you could trap the RadGrid1_DetailTableDataBind event to capture the row ID that was being opened, and execute a query *at that time* against data that may *not* be related to the primary table via a foreign key.  But in your current implementation, I'm not getting the concept so easily.  Can you explain what I'm missing?

    thanks
  7. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 07 Sep 2009 Link to this post

    Hello Chris Williams,

    Now I see. In this case I would reccomend using the Row Details feature it implement this on-demand functionality. I have written a blog post that describes how to display hierarchical data by using Row Details. Please, examine it and you should get going in no time.

    The RowDetails equivalent of OnExpandedRowStateChanged is called RowDetailsVisibilityChanged. This event is fired when row details are shown or hidden.

    You can have full control over each individual GridViewRow through its DetailsVisibility property. Actually, in my blog post the toggle button in the leftmost column uses this property to show / hide row details, but you can do it programmatically from anywhere since the DetailsVisibility property is public.

    Changing this property will result in the above mentioned RowDetailsVisibilityChanged event being fired for the grid. In the EventArgs of the event you will have the GridViewRow for which the details have been shown or hidden. To check whether they were shown or hidden you can read the e.Row.DetailsProvider.DetailsVisibility property.


    In the last version of RadGridView RowDetails are "on demand" by design. The RowDetails template (the place where you will place you child grid) will be lazy loaded the first time when a user wants to see the child data. But since you want a trip to the DB to be made each time a user wants to see child data I will propose the following.

    Place an unbound grid in the RowDetails template. Then subscribe to the RowDetailsVisibilityChanged event of the grid and do the job there each time a RowDetails is being show. You have all the data in the event args. e.Visibility will be Visible if the details are being shown. You can find the master entity (your row ID) from e.Row.DataContext. And e.DetailsElement will give you the control you have placed in the RowDetailsTemplate. You can find the grid now and bind it to the child data. It is that simple.

    I hope this helps. Please, let me know if you have any other questions.

    Regards,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Nikhil Agrawal
    Nikhil Agrawal avatar
    1 posts
    Member since:
    Oct 2009

    Posted 10 Nov 2009 Link to this post

    Hi

    I have the same problem. I have list of Column that has to put for the different Grid (level 0, 1, 2,3 ...)
    I have no idea about about the Level of nesting on the design time. I will get the collection of object that will bind to first grid.
    what will have Indexer property for the chilc collection.
    and I would have the list Grid Column, with UniqueName, LayoutIndex, Layout Properyname

    Ex:

    List 1 (ID , Name , Property("ChildCollection") = List(of ListItem2))
    ListItem2  (ID , Name , Property("Child1Collection") = List(of ListItem3))
    ListItemN-1  (ID , Name , Property("ChildCollection") = List(of ListItemN))
    ListItem  (ID , Name , Property("ChildCollection") = nothing)

    GridColumn List as below
    1) ID,0,""'
    2) Name,0,""'
    3) ListItem2.ID,1,"ChildCollection"'
    4) ListItem2.Name ,1,"ChildCollection"'
    5) ListItem3.ID,2,"Child1Collection"'
    6) ListItem3.Name ,2,"Child1Collection"'

    Can we have dynamic adding of the HirechicalTemplate with RadGridView Inside.




  9. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 11 Nov 2009 Link to this post

    Hi Nikhil Agrawal,

    In order to achieve this you need to add as many nested ChildTableDefinitions to grid as needed. The structure of these nested ChildTableDefinitions should match the structure of your nested custom objects.
    In each ChildTableDefinition you will set the correct PropertyRelation according to the child collection name.

    Please consult all the help topics under this help topic for more information on creating hierarchies with ChildTableDefinitions. I hope this helps.

    Regards,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. p k
    p k avatar
    6 posts
    Member since:
    Dec 2009

    Posted 17 Dec 2009 Link to this post

    Hi,
    I tried this sample application and it works fine with existing Telerik dlls. But when i remove and add reference of telerik controls of version 2009.2.812.1030, i am not getting child rows. Its coming as empty row.
    Please help.

    Thanks
  11. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Dec 2009 Link to this post

    Hello p k,

    We have introduced some changes lately and you will need to change several things.

    1. Use an empty child table definition to force the grid to show the hierarchy child template.
    2. Set the ItemsSource of the grid that is inside the HierarchyChildTemplate.

    Alternatively, you can display hierarchies by using the Row Details feature. You will define a row details template containing a RadGridView's inside it. This RadGridView will have its ItemsSource bound to the collection property of your business object.

    As a matter of fact you can place anything you like inside the RowDetailsTemplate. To learn how to show hierarchical data with RadGridView, please follow my blog post How To: Display Hierarchical Data with Row Details and consult the documentation.

    I hope this helps.

    Regards,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. p k
    p k avatar
    6 posts
    Member since:
    Dec 2009

    Posted 22 Dec 2009 Link to this post

    Hi Ross,

    Thanks for the reply. We are creating the grid columns and Hierarchy Child during runtime. Currently we are using Telerik Version 2009.3.1208.1030. In code behind the "dataControl.ParentRow" always returns null and we are unable to add child columns.

    XAML

    <UserControl x:Class="NestedHierarchyChildTemplates.MainPage" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"   
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"   
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">  
        <Grid> 
            <telerik:RadGridView Name="clubsGrid"   
                                 AutoGenerateColumns="False" 
                                 DataLoading="RadGridView_DataLoading" 
                                 ColumnsWidthMode="Auto">  
                <telerik:RadGridView.HierarchyChildTemplate> 
                    <DataTemplate> 
                        <telerik:RadGridView  
                            Name="playersGrid"   
                            ShowGroupPanel="False" 
                            AutoGenerateColumns="False" 
                            ColumnsWidthMode="Auto">  
                            <telerik:RadGridView.Columns>   
                                  
                            </telerik:RadGridView.Columns>                          
                        </telerik:RadGridView> 
                    </DataTemplate> 
                </telerik:RadGridView.HierarchyChildTemplate> 
            </telerik:RadGridView> 
        </Grid> 
    </UserControl> 
     

    Code Behind:

    public partial class MainPage : UserControl  
        {  
            public MainPage()  
            {  
                InitializeComponent();  
     
                GridViewDataColumn DcName = new GridViewDataColumn();  
                DcName.Header = "Name";  
                DcName.DataType = typeof(string);  
                DcName.IsGroupable = false;  
                DcName.IsSortable = false;  
                Binding bind = new Binding { Path = new PropertyPath("Name") };  
                DcName.DataMemberBinding = bind;  
                clubsGrid.Columns.Add(DcName);  
     
     
                GridViewDataColumn DcEstablished = new GridViewDataColumn();  
                DcEstablished.Header = "Established";  
                DcEstablished.DataType = typeof(string);  
                DcEstablished.IsGroupable = false;  
                DcEstablished.IsSortable = false;  
                bind = new Binding { Path = new PropertyPath("Established") };  
                DcEstablished.DataMemberBinding = bind;  
                clubsGrid.Columns.Add(DcEstablished);  
     
                GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition();  
                playersTableDefinition.Relation = new PropertyRelation("Players");  
                this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition);  
     
                  
                this.clubsGrid.ItemsSource = Club.GetClubs();  
            }  
     
            private void RadGridView_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)  
            {  
                GridViewDataControl dataControl = (GridViewDataControl)sender;  
                if (dataControl.ParentRow != null) //The ParentRow property always returns null  
                {  
                    dataControl.CanUserFreezeColumns = false;  
                    dataControl.ShowGroupPanel = false;  
                    dataControl.AutoGenerateColumns = false;  
     
                    GridViewDataColumn column = new GridViewDataColumn();  
                    column.Header = "Name";  
                    column.DataMemberBinding = new System.Windows.Data.Binding("Name");  
                    dataControl.Columns.Add(column);  
     
                    column = new GridViewDataColumn();  
                    column.Header = "Country";  
                    column.DataMemberBinding = new System.Windows.Data.Binding("Country");  
                    dataControl.Columns.Add(column);  
     
                }  
            }  
        } 

    Please provide a sample application as to how we can display the child Grid Columns.

    Thanks
    p k

  13. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Dec 2009 Link to this post

    Hi p k,

    Use Row Details.

    Attach to the LoadingRowDetails event. It is fired the very first time row details are loaded. If you need to do this stuff every time row details are shown, then attach to the RowDetailsVisibilityChanged event.

    From the event args you will have the row for which details are loaded / shown (i.e. your parent row) and the DetailsElement you have specified in the RowDetailsTemplate. From this element you can find your nested grid (if it is not the grid itself) and add any columns that you like and do anything additional.

    Please, consult the documentation and the blog post I mentioned for more information.

    Greetings,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. Lauren
    Lauren avatar
    37 posts
    Member since:
    Jan 2010

    Posted 23 Apr 2010 Link to this post

    Hi,

    I'm having the same issue here as the initial post, but i still cant quite understand how to do that...

    I have a radgridview and a rowDetailsTemplate. The RowDetailsTemplate contains another grid which i need to bind dynamically on LoadingRowDetails using a web service call.

    so in the LoadingRowDetails method, i have indeed access to e.Row and e.DetailsElement in that method. But then i call my web service and once the web service return, i'm in the method <methodName>Completed. So it's actually in this method that i want to bind the grid within the RowDetailsTemplate. But then in that method i can't find out how to access the template...

    I just started working with grid and row details, so my question might seem obvious to some, but i'm at a loss.

    Any suggestion ?
    Thanks for your help.

    ---------------MainPage.xaml.cs---------------------

    private

     

    void ResultGrid_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e)

     

    {

     

     

        string param = e.Row.GetCellFromPropertyName("column1").Value.ToString();

     

     

     

     

     

        RadTabControl rowTabControl = e.DetailsElement as RadTabControl;

     

     

        RadGridView rowDetailsGrid = rowTabControl.FindName("jobGrid") as RadGridView;

     

        (...)

     

        // Call WS

     

        WrapperReference.

    WrapperWSClient cl = new Results.WrapperReference.WrapperWSClient();

     

        cl.GetGridCompleted +=

    new EventHandler<Results.WrapperReference.GetGridCompletedEventArgs>(cl_GetGridCompleted);

     

        cl.GetGridAsync(param

    );

     

    }

     

    void cl_GetGridCompleted(object sender, SL_Results.ERCWrapperReference.GetGridCompletedEventArgs e)

     

    {
          ????? i need to create the grid column and bind them dynamically.
    }

    ---------------MainPage.xaml---------------------

     

    <

     

    telerikGridView:RadGridView x:Name="grid1"

     

     

        LoadingRowDetails="ResultGrid_LoadingRowDetails">

     

     

     

        <telerikGridView:RadGridView.Columns>

     

     

     

            <telerikGridView:GridViewToggleRowDetailsColumn />

     

     

     

        </telerikGridView:RadGridView.Columns>

     

     

     

        <telerikGridView:RadGridView.RowDetailsTemplate>

     

     

     

            <DataTemplate>

     

     

     

                <telerikNavigation:RadTabControl x:Name="DetailsTabs">

     

     

     

                    <telerikNavigation:RadTabItem x:Name="item1"

     

     

                                                                     Header="Details">

     

     

     

                        <TextBlock x:Name="tb" Text="Hello!" />

     

     

     

                    </telerikNavigation:RadTabItem>

     

     

     

                    <telerikNavigation:RadTabItem x:Name="abc"

     

     

     

                                                                    Header="abc">

     

     

     

                        <telerikGridView:RadGridView x:Name="item2">

     

     

     

                        </telerikGridView:RadGridView>

     

     

     

                    </telerikNavigation:RadTabItem>

     

     

     

                </telerikNavigation:RadTabControl>

     

     

     

            </DataTemplate>

     

     

     

        </telerikGridView:RadGridView.RowDetailsTemplate>

     

     

     

    </telerikGridView:RadGridView>

     

  15. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 26 Apr 2010 Link to this post

    Hi Lauren,

    This blog might help you.

    Generally, you can encapsulate the entire row details template in a new user control. From withing this user control you will have access to the child grid. You can then create a public method on the user control which will start retrieving the data and then when it is done you will assign it to grid. The architectural approaches are many.

    Best wishes,
    Ross
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  16. Chen
    Chen avatar
    18 posts
    Member since:
    Apr 2012

    Posted 24 Apr 2012 Link to this post

    Hi Ross,

    I tried your sample attached project, it worked fine for the verion you used in the Binary folder. But when I used the updated version (2012.1.0215.1050), it did not work. The sub list in the hierarchy gridview did not show up.

    I was wondering if you were aware of this and had a fix for it.

    Thanks,
    Chen
  17. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 25 Apr 2012 Link to this post

    Hello,

    This blog post is very very ancient and this is not the preferred way anymore.

    Please, check this online example.

    All the best,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  18. Rob Conley
    Rob Conley avatar
    47 posts
    Member since:
    Sep 2012

    Posted 10 Jan 2013 Link to this post

    The example uses the RadDomainDatasource, and I think a lot of us are taking an MVVM approach. It would help you could point out what specific approaches are obsolete and/or how to handle this issues discussed in this thread with an MVVM approach.
Back to Top
DevCraft banner