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

DataRow Visibility

1 Answer 22 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Collins
Top achievements
Rank 1
David Collins asked on 10 Sep 2009, 03:10 PM
I am looking for a way to hide certain rows based on properties of the row's datacontext.  I've tried setting the MinHeight property of the row (as suggested in another thread).  The problem is the row has text and shrinks to the text height.  Is there some other way to control the visibility of individual rows in the grid?

1 Answer, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 11 Sep 2009, 05:19 AM
Hello David Collins,

You could use RadGRidView's DataLoaded event and change the size of some specific rows there:

void playersGrid_RowLoaded(object sender, RowLoadedEventArgs e)  
{  
    if (e.Row is GridViewHeaderRow || e.Row is GridViewNewRow || e.Row is GridViewFooterRow)  
        return;  
 
    GridViewRow row = e.Row as GridViewRow;  
    Player player = row.DataItem as Player;  
 
    if (player.Position == Position.DF || player.Position == Position.MF)  
    {  
        row.MinHeight = 0;  
        row.Height = 0;  
    }  
 

The trick is that you should set both Height and MixHeight to 0.

If you only need to hide certain rows you could try to use our filtering mechanism which is probably a better fit for this scenario.
http://www.telerik.com/help/wpf/gridview-setting-filters-programmatically.html

I am also sending you a sample project that demonstrates the first approach.

Kind regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
David Collins
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or