This is a migrated thread and some comments may be shown as answers.

Different child templates on second level hierarchical model

2 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
flisak
Top achievements
Rank 1
flisak asked on 14 Mar 2012, 12:15 AM
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 Answers, 1 is accepted

Sort by
0
flisak
Top achievements
Rank 1
answered on 14 Mar 2012, 12:20 AM
Sorry for fonts... I have not found possibility to change this...
0
Accepted
Jack
Telerik team
answered on 16 Mar 2012, 10:44 AM
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 >>
Tags
GridView
Asked by
flisak
Top achievements
Rank 1
Answers by
flisak
Top achievements
Rank 1
Jack
Telerik team
Share this question
or