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

Setting individual row heights

1 Answer 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 03 Oct 2014, 08:40 AM
Hi,

I am trying to set different row heights on a row depending on a value in the underlying data.

So far I have worked out I can do the following...

var rows = rgv.ChildrenOfType<GridViewRow>();

int counter = 0;

foreach (GridViewRow gridViewRow in rows)
{
    gridViewRow.Height = 20.0 + counter;
    counter += 10;
}

This will set each row height to be 10 greater than its predecessor. The issue with this method is that the datagrid seems to calculate the height of the "rowspanel" based on the standard rowheight property and does not draw a vertical scroll bar, and also draws the horizontal scroll bar off the bottom of the visible area where it is not accessible.

My questions are is there a better way to achieve what I want? Maybe apply a style to the row whose height is bound to a property in the underlying data? Or is there some method I can call to "refresh" the datagrid to make it draw the horizontal scroll bar in the correct place and detect it needs to draw a vertical scroll bar.

Thanks

Andy


1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 06 Oct 2014, 01:14 PM
Hi Andy,

It seems you work with the visual elements, i.e. GridViewRows in your solution and this approach has some flaws. 
I should note that RadGridView is a virtualized control and as such, due to the UI Virtualization, if the row is not in the View port, then there will not be a GridviewRow realized for displaying the respective Item. When the virtualization of RadGridView is turned on (which is by default), its elements are created when they should be brought into view. You can take a look at this article for a reference on UI Virtualization.

You can try applying a RowStyleSelector instead. Still please keep in mind that RadGridView will work better in matters of performance and scrolling if all the rows have the default height.

Regards,
Dimitrina
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or