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

[Solved] Grid Resizing issue

2 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 02 Feb 2013, 03:56 PM
Hi have a grid with paging on it. I want it to be resized (including the pager) whenever I resize the form or change the pager size/index.
I have the following code:
<telerik:RadCodeBlock runat="server" ID="MainScriptBlock">
        <script type="text/javascript">
            window.$ = $telerik.$;
 
            jQuery.event.add(window, "load", resize);
            jQuery.event.add(window, "resize", resize);
 
            function resize() {
                var h = $(window).height();
                $(".resizeGrid").css({ 'height': (h - 60) });
            }
        </script>
    </telerik:RadCodeBlock>

1. The grid loads ok the first time it is loaded i.e. the grid + pager are aligned to the footer.
2. When I change the pager size to say 20 from 50. The grid + pager moves up and is no longer aligned to the footer.
3. Same thing happens when I change the page index.
3. If I resize the form, the pager moves down and aligns itself with the footer (which is what I want)

How do I fix the above behavior in step 2 and 3 above so that the grid resizes each time?

2 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 02 Feb 2013, 04:33 PM
I noticed the OnGridCreated event in the documentation. Can anybody tell me if this event is fired every time the grid is reloaded after the pager size/index change? Here is my grid definition on the .aspx page

<telerik:RadGrid ID="RadGrid1" CssClass="resizeGrid" runat="server" ShowGroupPanel="True"
            ShowStatusBar="true" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="false"
            EnableViewState="true" AutoGenerateColumns="False" PageSize="50" AllowMultiRowSelection="false"
            OnItemDataBound="RadGrid1_ItemDataBound" OnNeedDataSource="RadGrid1_NeedDataSource"
            PagerStyle-AlwaysVisible="true">
0
Kostadin
Telerik team
answered on 06 Feb 2013, 01:37 PM
Hello James,

I confirm that OnGridCreated client event is fired every time when page size is changed. The following code snippet demonstrated how you can hook it.
JavaScript:
function GridCreated(sender, args) {
   //your code here
}
Mark-Up:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"   AllowPaging="true"  PageSize="5">
    <ClientSettings>
        <ClientEvents OnGridCreated="GridCreated" />
    </ClientSettings>
</telerik:RadGrid>


Regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or