Multiple Child Templates

4 posts, 0 answers
  1. Josh
    Josh avatar
    1 posts
    Member since:
    Jul 2011

    Posted 24 Aug 2011 Link to this post

    Hi there,

    I'm currently evaluating the Telerik RadControls for WinForms and I'm trying to accomplish something with the DataGrid component. I am wondering if there is any way to specify different child templates for the top level rows in the grid.

    I have a dataset that consists of a List<ICommonData>. I have 2 classes (say ClassA and ClassB) that implement ICommonData. My datasource contains a list of both ClassA and ClassB objects. The parent rows of the grid show all the properties declared in ICommonData. What I want is when the user expands the parent row, I want them to see a sub grid that shows other ClassA or ClassB columns depending on what data object that row was bound to. Basically I need the ability to specify dynamically which template each row uses when displaying the child grid.

    Is there any way to do this?

    Thanks,
    Josh
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 29 Aug 2011 Link to this post

    Hello Josh, I answered to your question in your support ticket regarding the same issue. Please avoid posting the same question twice, as this may slow down our response. Thank you for your understanding.

    Should you have any other questions, do not hesitate to ask.
     
    Regards,
    Jack
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Miloš Sommer
    Miloš Sommer avatar
    2 posts
    Member since:
    Jan 2010

    Posted 01 Sep 2011 Link to this post

    Hello,

    could you send me an answer for Josh too, please?

     

    I think it can solve my problem i have written here:

    http://www.telerik.com/community/forums/winforms/gridview/hiearchical-grid.aspx


    Thank you Misa.
  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 02 Sep 2011 Link to this post

    Hi Michaela,

    As requested, I am posting here my response to the question from Josh:

    "Hi Josh,

    Thank you for contacting us.

    Yes, this is possible. Please take a look at the GridView - Hierarchy - Tabbed Views example in our demo application. It implements a highly similar scenario - a parent view that relates to many child views. The child views are presented in different tabs. You can find more information in this topic in our online documentation.

    All you need to do is hide the desired tab programmatically. This can be done when handling theViewCellFormatting event. Please consider the code snippet below:"

    Copy Code
    this.radGridView1.ViewCellFormatting += newCellFormattingEventHandler(radGridView1_ViewCellFormatting);
     
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement;
        if (cell != null)
        {
            GridViewDetailsRowInfo detailsRow = (GridViewDetailsRowInfo)cell.RowInfo;
            GridViewHierarchyRowInfo hierarchyRow = (GridViewHierarchyRowInfo)detailsRow.Owner;
            if (hierarchyRow.Index % 2 == 0)
            {
                cell.PageViewElement.Items[0].Visibility = ElementVisibility.Visible;
            }
            else
            {
                cell.PageViewElement.SelectedItem = cell.PageViewElement.Items[1];
                cell.PageViewElement.Items[0].Visibility = ElementVisibility.Collapsed;
            }
        }
    }

    I hope this helps. We will answer your question in your forum post.

    Should you have any other questions, do not hesitate to ask.
     
    All the best,
    Jack
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top