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

grid is contained in a div. make div change size on grid changing size.

3 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lina fetisova
Top achievements
Rank 1
lina fetisova asked on 17 Sep 2010, 12:10 PM
Good day!
I have a grid on page, it has width 100% and height 100%
The grid is contained in a div. When I change pagimng size or when I go through pages in pagin height of the grid changes but the div's height does not =(   And it looks bad. How can I make div change size on grid changing size? What RadGrids client events should I use for it?

3 Answers, 1 is accepted

Sort by
0
lina fetisova
Top achievements
Rank 1
answered on 17 Sep 2010, 12:16 PM
I try to do this way:

<telerik:RadGrid  ID="grClients" runat="server" GridLines="None" AllowPaging="True"
          AllowAutomaticInserts="True" AllowAutomaticUpdates="True"  AllowFilteringByColumn="True"
          AllowSorting="True"  PageSize="50"   Skin="Windows7"
        OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="False"
        ShowGroupPanel="True" Width="100%" Height="100%" GroupPanel-Width="100%"
        OnPageIndexChanged="AjaxSizeChanged" OnPageSizeChanged="AjaxSizeChanged"></telerik:RadGrid>

 <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
    <script type="text/javascript">
function AjaxSizeChanged(sender, eventArgs) {
            var grid = $find("<%=grClients.ClientID %>");
            document.getElementById('divLO').style.height = grid.style.height;
        }
</script>
        </telerik:RadCodeBlock>

and I have such an error:

"ASP.allclients_aspx" does not contain a definition for "AjaxSizeChanged". Could not find the extension method "AjaxSizeChanged", taking the first argument of type "ASP.allclients_aspx"
0
Dimo
Telerik team
answered on 17 Sep 2010, 04:07 PM
Hi Lina,

PageSizeChanged is a server event and requires a server handler, which you obviously don't have. However, a server handler will not help you to change the <div>'s height.

If you want the RadGrid parent <div> to change its height according to the RadGrid height, then simply do not set any height to the <div>. If you want the RadGrid control to be 100% high, then also set a 100% height style to the <div>.

If you have some more complex logic, which should determine the <div>'s height, then use the RadGrid's OnGridCreated client event.

http://www.telerik.com/help/aspnet-ajax/grid_ongridcreated.html

By the way, you should change the following in your Javascript code:

grid.style.height

to

grid.get_element().offsetHeight



Kind regards,
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
0
lina fetisova
Top achievements
Rank 1
answered on 21 Oct 2010, 04:47 AM
Dimo, thank you very much! now everything is allright!=)
Tags
Grid
Asked by
lina fetisova
Top achievements
Rank 1
Answers by
lina fetisova
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or