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

Collapsing a DetailsGrid

6 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
marco kannenberg
Top achievements
Rank 1
marco kannenberg asked on 22 Feb 2010, 11:41 AM
hello,

i'm having a problem collapsing a details grid from within the details grid. the master grid has a GridViewToggleRowDetailsColumn to display details and close them. the problem is, there is a button in the details grid (of type RowDetailsTemplate) which does some operation and afterwards should close the details automatically. i'm using event LoadingRowDetails so using a HierarchyChildTemplate is a problem.
how can i collapse the details grid with the button inside?




since the documention is very poor on wpf controls i'm having difficulties figuring out which property and which method does what. examples (how to's) are really appreciated.


thanks,

6 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Feb 2010, 12:40 PM
Hello marco kannenberg,

From within your row details control (which, in fact, can be anything in the world), you can find the the parent row (i.e. the parent row below which your row details control is displayed) by using the ParentOfType<GridViewRow>() method. Since we do not know what our customers will put inside the RowDetailsTemplate, there is no way for us to create something that will collapse row details from the inside. That is why you will need to add this custom logic.

Once you have the a reference to the parent GridViewRow, you only need to set its DetailsVisibility property to Collapsed. This will hide its row details.

The ParentOfType<T> extension method is located in the Telerik.Windows.Controls namespace.

Try this and let us know if you have any trouble implementing it.

Documentation regarding row details you can find here. I hope this helps.

Kind regards,
Ross
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
marco kannenberg
Top achievements
Rank 1
answered on 22 Feb 2010, 01:19 PM
hello ross,


maybe i'm missing the point in your answer. the button is within a stackpanel which is in the DataTemplate of the RowDetailsTemplate. how do i get the row again? i can't find any ParentOfType extension method.

regards,
marco


0
Accepted
Rossen Hristov
Telerik team
answered on 22 Feb 2010, 01:56 PM
Hi marco kannenberg,

You can do this in the button click event handler:

using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
...
var parentRow = this.ParentOfType<GridViewRow>();
parentRow.DetailsVisibility = Visibility.Collapsed;
...

Try this and see how it goes.

All the best,
Ross
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
marco kannenberg
Top achievements
Rank 1
answered on 22 Feb 2010, 02:15 PM
it works now.

thanks,
marco
0
jas
Top achievements
Rank 1
answered on 22 Mar 2010, 12:48 PM
Since clicking a row expands the details area, would it not be possible to allow the option of clicking the row again to collapse the details area? (certainly this is what my users try to do!)

jas
0
Milan
Telerik team
answered on 22 Mar 2010, 01:47 PM
Hi jas,

One of the selection modes that is currently available, called Multiple, might help you. When RadGridView uses this mode rows can be selected/deselected with a single mouse click - for example, if a row is already selected, performing a click on this same row will automatically deselect it and ultimately its corresponding details will be collapsed. Unfortunately this selection mode also allows several items to be selected at the same time and I am not sure if that mode is suitable for your scenario. 


Greetings,
Milan
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
marco kannenberg
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
marco kannenberg
Top achievements
Rank 1
jas
Top achievements
Rank 1
Milan
Telerik team
Share this question
or