Different child templates on second level hierarchical model

3 posts, 1 answers
  1. flisak
    flisak avatar
    6 posts
    Member since:
    Jan 2012

    Posted 13 Mar 2012 Link to this post

    Hi,

    Is it possible to configure RadGridView to have different child templates on the same level of hierarchical data rows? Or to have different columns collections for each group?

    I want to accomplish something like this:

    [Data model]
    Class Flat
    {
     string name; 
     List<Room> rooms;
    }

    Class Room
    {
     string name;
     bool table;
     bool bath;
     bool desk;
     int walls;
    }

    [View]

    1. Expandable rows with objects  "Flat" (visible columns: Name)
    2. Second hierarchy with rooms, but on this level different columns visible for every room type:

    If room name is "Bathroom" then columns are: name, bath, walls.
    If room name is "Saloon" then columns are: name, table, walls.
    etc.

    Is it feasible on one grid?

    Best Regards
     Krzysztof

  2. flisak
    flisak avatar
    6 posts
    Member since:
    Jan 2012

    Posted 13 Mar 2012 Link to this post

    Sorry for fonts... I have not found possibility to change this...
  3. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 16 Mar 2012 Link to this post

    Hello Krzysztof,

    This option is not available in RadGridView by design. Child views at the same level that have a common template share the same DataSource and the same Columns collection. However, you can add multiple child templates to a parent template. This scenario is demonstrated in our demo application. Check the GridView >> Hierarchy >> Tabbed Views example. You can control the tab visibility by handling the ViewCellFormatting event. Consider the sample below:
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement;
        if (cell != null)
        {
            cell.PageViewElement.Items[1].Visibility = ElementVisibility.Collapsed;
        }
    }

    I hope this helps. If you need further assistance, I will be glad to help.
     
    All the best,
    Jack
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top