I have a hierarchical grid in which a parent table has 2 child tables, each with different columns. Basically, a row in the parent table has 2 columns that hold collections of objects. For each of those collection types, I created a GridViewTableDefinition with a PropertyRelation to associate the parent table column to a child table. This works fine, but I am trying to find a way to expose the GridViewTableDefinition.PropertyRelation.Name above the child table.
I have seen an example in the forums that shows a RadGridView with multiple child data in tab controls. The tabs show the Relation.Name which is what I want, but I don't want to use the tab controls.
I think what I really want is closer to the RadTreeListView, but the RadTreeListView is only used for displaying homogenous data... and mine is heterogeneous.
I basically want a TreeView with columns so that I can display properties of heterogeneous object types. Is this possible with a RadGridView?
Kind Regards,
Albert
9 Answers, 1 is accepted
What you can do is to subscribe to the Loaded event of the child RadGridView. Then you need to find the name of the child table (through the TableRelation) and set it to a HeaderedContentControl (for example):
private
void
RadGridView_Loaded(
object
sender, RoutedEventArgs e)
{
var dataSet =
this
.gridView.ItemsSource
as
DataSet;
var childGrid = sender
as
RadGridView;
var relationName = childGrid.TableDefinition.Relation.Name;
var sourceRelation = dataSet.Relations[relationName];
var parentHeaderedControl = childGrid.ParentOfType<HeaderedContentControl>();
parentHeaderedControl.Header = sourceRelation.ChildTable.TableName;
}
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

The call to
var parentHeaderedControl = childGrid.ParentOfType<
HeaderedContentControl
>();
var parentHeaderedControl = childGrid.ParentOfType<
Telerik.Windows.Controls.QuickStart.HeaderedContentControl
>();
but that returned null too.
Is there something I must set in the grid before a grid will have a non-null HeaderedContentControl parent?
Kind Regards,
Albert
I have attached a sample project. Please check it and let me know how it works for you?
Regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

From running your sample application, I see that when I expand a parent row I see a child grid for "Contact" and another child grid for "Subcategory". Is there any way to collapse (and then expand) the child grids while keeping the parent row expanded?
Kind Regards,
Albert
You can place the two detail GridViews in an additional control to take care of their expanded/collapsed state.
Kind regards,
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

In the sample application, the RadGridView.ItemsSource is set to a DataSet and RadGridView automatically renders the detail GridViews based on the DataRelations in the DataSet. I am not sure where the additional control goes.
Is there a property that enables/disables an expand/collapse button on a detail GridView?
Kind Regards,
Albert
What I meant is to change the "ChildDataControlsPresenterTemplate" like so:
<
DataTemplate
>
<
HeaderedContentControl
>
<
telerik:RadExpander
>
<
telerik:RadGridView
Loaded
=
"RadGridView_Loaded"
IsTabStop
=
"{Binding IsTabStop, ElementName=PART_ChildDataItemsControl}"
/>
</
telerik:RadExpander
>
</
HeaderedContentControl
>
</
DataTemplate
>
Greetings,
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

The RadExpander button looks like (^) (\/). Is there a way to make it simply look like the [-] [+] expander button that the top-level parent rows have?
Kind Regards,
Albert
If you would like to style the RadExpander, then you can edit its Template and add some additional logic which is not a trivial task. Still you can place the child GridView in any other control you find good enough.
Kind regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.