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

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

3 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 08 Apr 2013, 07:45 PM
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?

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 09 Apr 2013, 08:37 AM
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.

0
Rod
Top achievements
Rank 1
answered on 09 Apr 2013, 01:53 PM
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?
0
Vanya Pavlova
Telerik team
answered on 09 Apr 2013, 02:26 PM
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.

Tags
GridView
Asked by
Rod
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Rod
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or