DataRow Visibility

2 posts, 1 answers
  1. David Collins
    David Collins avatar
    3 posts
    Member since:
    Sep 2009

    Posted 10 Sep 2009 Link to this post

    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?
  2. Answer
    Milan avatar
    1989 posts

    Posted 11 Sep 2009 Link to this post

    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)  
        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.

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

    Kind regards,
    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.
Back to Top