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

[Solved] Get height of grid

2 Answers 215 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Hollen
Top achievements
Rank 1
Dave Hollen asked on 11 Feb 2010, 07:52 PM
    Hello,

How can I get the height of the grid each time it is resized (either by changing the Page size, number of records in the grid, etc.). 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2010, 09:41 AM
Hi Dave,

In order to find the height of an HTML element, you can use the offsetHeight Javascript property.

     var grid_height = $find('<%=RadGrid1.ClientID%>').get_element().offsetHeight;

Checkout the forum to know more about this.

Thanks,
Princy.
0
Dimo
Telerik team
answered on 12 Feb 2010, 09:41 AM
Hi Dave Hollen,

You can obtain the RadGrid height with Javascript like this:

$get("<%= RadGrid1.ClientID %>").offsetHeight

or

$find("<%= RadGrid1.ClientID %>").get_element().offsetHeight

Do not forget to enclose the <script type="text/javascript"> tag in a <telerik:RadCodeBlock> control in order to prevent exception caused by the presence of server code blocks (<%= %>).

If you are calculating the height in a RadGrid client event handler, then you can use

sender.get_element().offsetHeight

(if we assume that "sender" is the first parameter in the handler definition)

All the best,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Dave Hollen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dimo
Telerik team
Share this question
or