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

Displaying Names Of Parent/Child Relations In Hierarchical Grid

9 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 03 Sep 2012, 10:15 PM
Hi, I'm a Telerik newbie.

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

Sort by
0
Dimitrina
Telerik team
answered on 04 Sep 2012, 07:03 AM
Hello,

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;
        }

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Albert
Top achievements
Rank 1
answered on 04 Sep 2012, 03:15 PM
Thank you for the reply, but the sample code is not working for me. 

The call to 

var parentHeaderedControl = childGrid.ParentOfType<HeaderedContentControl>();


is returning null. HeaderedContentControl was resolving to System.Windows.Controls.HeaderedContentControl so I also tried 
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
0
Dimitrina
Telerik team
answered on 06 Sep 2012, 11:55 AM
Hello,

 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.

0
Albert
Top achievements
Rank 1
answered on 06 Sep 2012, 03:23 PM
Thanks for the reply, Didie.

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
0
Dimitrina
Telerik team
answered on 06 Sep 2012, 03:28 PM
Hi,

 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.

0
Albert
Top achievements
Rank 1
answered on 06 Sep 2012, 03:39 PM
Thanks for the quick response. Can you elaborate on what you mean by "placing the two detail GridViews in an additional control", please?

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
0
Dimitrina
Telerik team
answered on 06 Sep 2012, 03:45 PM
Hi,

 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.

0
Albert
Top achievements
Rank 1
answered on 06 Sep 2012, 03:56 PM
Oh neat!

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
0
Dimitrina
Telerik team
answered on 10 Sep 2012, 12:34 PM
Hello,

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.

Tags
GridView
Asked by
Albert
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Albert
Top achievements
Rank 1
Share this question
or