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

Non-grid, non-template hierarchical children

3 Answers 41 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Moe Aboulkheir
Top achievements
Rank 1
Moe Aboulkheir asked on 03 Jun 2010, 10:03 PM
Hi,

I've recently started trying to use the RadGridView again.

Generally, I like the look of the hierarchy feature.  Unfortunately, it doesn't seem to easily support my use case.

When a row is expanded, what I would like to be able to do is put an arbitrary element in its detail/child area.  I don't want to use a template - I already have a FrameworkElement instance in my view model that I want to display under the row.  How might I go about this?

Take care,
Moe

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 09 Jun 2010, 12:22 PM
Hello Moe Aboulkheir,

Using the HierarchyChildTemplate of RadGridVIew , you may place  any control in the hierarchy and bind its content to the instance contained in your ViewModel.
Alternatively you may do this programmatically by handling the loaded event of a control in the hierarchy child
 and adding the instance as a visual child.
In case you have troubles  implementing this approach , just paste me the implementation of your ViewModel and I will try to prepare a small sample for you.

Kind regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Moe Aboulkheir
Top achievements
Rank 1
answered on 17 Jun 2010, 10:39 AM
Pavel,

Thanks for the answer.  I'm still not really clear how to do this cleanly, though.

In my case, the constructor for the view model of the details view depends on information from the current row in the parent grid.  Something like this:

public class RowDetailViewModel { 
    public RowDetailViewModel(RowViewModel row) { 
        ... 
    } 
 
public class RowViewModel { 
    ... 


And in the grid's view model, what I would like to be able to do is something like:

void OnExpandDetails(GridRowView row) { 
    var rowViewModel = (RowViewModel)(row.DataContext); 
    var detailViewModel = new RowDetailViewModel(rowViewModel); 
    row.SetDetail(detail); 

Except that there's nothing like OnExpandDetails or SetDetail :).  Your suggestion of doing something in the Loaded event of the details template is not going to work very well, in my case, because there may be other state I need to pass into the constructor of the detail view model from the grid view model.

Take care,
Moe
0
Vlad
Telerik team
answered on 21 Jun 2010, 07:40 AM
Hello Moe,

 Have you tried RowDetailsVisibilityChanged event?

Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Moe Aboulkheir
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Moe Aboulkheir
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or