How do I restrict what's displayed in a GridView to only the data shown?

4 posts, 0 answers
  1. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 08 Apr 2013 Link to this post

    I hope my question makes sense. I've got some test data which will better illustrate what I'm trying to convey.

    Here's a link on my Flickr account, to the photo (I can't find any other way to show the pic on this forum).

    Bottom line, when the application is running and the user types in search parameters which shows fewer rows than what the GridView normally has in it, I'd like the white area, which currently shows up in the grid, to not be there. I did a search on this forum, but only found results related to row height. I don't believe the row height is my problem, it's the height, or space, taken up by the GridView. How do I eliminate the unneeded white space?
  2. Yoan
    Admin
    Yoan avatar
    1180 posts

    Posted 09 Apr 2013 Link to this post

    Hi Rod,

    You can place RadGridView in a Grid with RowDefinition. Then you can set RowDefinition's Height to "Auto'. Please keep in mind, that if you have many items, you can set GridView's MaxHeight property.

    I hope this is what you need.

    Regards,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 09 Apr 2013 Link to this post

    Hi Yoan,

    OK, just to make sure I've got what you're saying, you're recommending that I place the Telerik RadGridView control within a WPF Grid, and that the row the RadGridView is in have a height of "Auto". But I should also set the RadGridView's MaxHeight property, just to make certain that it doesn't get too large. Is that what you're saying?
  4. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 09 Apr 2013 Link to this post

    Hi Rod,

     

    Let me try to shed some light on that matter. As my colleague Yoan explained you may position RadGridView within RowDefinition with Height set to Auto. In this way RadGridView is measured with infinity, which means that all items are recreated at once and the virtualization is turned off.
    Indeed this is the easiest way to achieve the desired result, however it leads to degraded performance. There is another hacky way to achieve the same with virtualization turned on.  The main idea behind this approach is to predefine the template of RadGridView and setting the VerticalAlignment property of the root container to Top: 


    <ControlTemplate x:Key="RadGridViewTemplate" TargetType="telerik:RadGridView">
                <Border VerticalAlignment="Top" x:Name="PART_MasterGridContainer" .....>
    </ControlTemplate >


    In this way all containing elements will be stacked to the aligned root container. 
    Hope this helps! 


    Kind regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top