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

RowDetailsVisibilityMode

3 Answers 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Michetti
Top achievements
Rank 1
Scott Michetti asked on 13 Feb 2014, 07:24 PM
Hello,
I was wondering if it is possible to set the RowDetailsVisibilityMode to Collapsed, but then in code set certain rows to show the details. I don't want the user to be able to show the details, but I may at times choose, for instance, row 2 and row 4 to show the details. Is this possible?

Thanks,
Scott

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 14 Feb 2014, 03:09 PM
Hi Scott,

You can achieve the desired results by changing the GridView's RowDetailsVisibility during the SelectionChanged event. You can also use the following logic during other events like button click. The next code snippet contains, a sample code displaying how to do this during the SelectionChanged event.
private void clubsGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
{
var selected = this.clubsGrid.SelectedItem as Club;
           
if (selected == this.clubsGrid.Items[2])
{
this.clubsGrid.RowDetailsVisibilityMode = Telerik.Windows.Controls.GridView.GridViewRowDetailsVisibilityMode.VisibleWhenSelected;
}
else
{
this.clubsGrid.RowDetailsVisibilityMode = Telerik.Windows.Controls.GridView.GridViewRowDetailsVisibilityMode.Collapsed;
 
}
}


Regards,
Hristo
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Scott Michetti
Top achievements
Rank 1
answered on 14 Feb 2014, 07:24 PM
Thanks Hristo, but that would only display 1 row detail, and it would have to be the one selected. What I'm looking for is a way to show rowdetails on certain rows, but not based on selection. So I would like to be able to show the row details for rows 2 and 4, at the same time, regardless of current selection, and hide the other row details. So it would be like setting the value to GridViewRowDetailsVisibilityMode.Visible, but hiding the details for rows 1,3,5,6,7, for instance. It seems that if you can show all the details at once, or just the details of selected rows, you should be able to set the details per row.

Thanks,
Scott
0
Hristo
Telerik team
answered on 17 Feb 2014, 02:04 PM
Hello Scott,

Thank you for the clarification. This result can be achieved by setting the DetailsVisibility property of each GridViewRow. Basically, you would have to create a list which contains all rows, and after that, to change the DetailsVisibility of the chosen rows.

I have also attached a demo project demonstrating this approach.

Regards,
Hristo
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
GridView
Asked by
Scott Michetti
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Scott Michetti
Top achievements
Rank 1
Share this question
or