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

Prevent autosize on post-back

1 Answer 115 Views
Window
This is a migrated thread and some comments may be shown as answers.
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 07 Feb 2014, 05:15 PM
I am using autosize on several of my radwindows successfully.

There are a few windows where I would like to have the window autosized when it loads, but after the initial load, disable autosize on further postbacks.

I am running into a situation where I load a radgrid in a radwindow to display some data with filtering and sorting enabled. If the user specifies a filter criteria which yields no records, the radwindow resizes so small that they cannot "unfilter" because clicking the filter button again opens a list which disappears off the top and bottom of the 'resized' radwindow.

By using autosize when the window first opens, I get a properly sized window. I'd like to be able to disable autosize after the window is opened so on future postbacks the window will not resize.

I attempted to add this code to client-size scripting, but it had no effect. Can someone suggest a method by which I can accomplish this? Thanks, Mike.

​       function pageLoad() {
var oWnd = null;
if (window.radWindow)
oWnd = window.radWindow;
else
if (window.frameElement.radWindow)
oWnd = window.frameElement.radWindow;
if (oWnd) {
window.setTimeout(function () { oWnd.autoSize(false); oWnd.set_autoSize(false); }, 500);
            }
}

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 10 Feb 2014, 01:24 PM
Hi,

Since you want autosizing only for the initial load I can suggest using the OnClientPageLoad event. Here are two ways you can have this done:
- no automatic autosizing, manually autosize only when needed, e.g.:
<telerik:RadWindow ID="RadWindow1" runat="server" AutoSize="false" OnClientPageLoad="OnClientPageLoad">
</telerik:RadWindow>
<script type="text/javascript">
    function OnClientPageLoad(wnd) {
        //with animation
        wnd.autoSize();
        //without animation:
        //wnd.autoSize(false);
    }
</script>

- OR, use autmatic autosizing, but disable it after the first time it autosizes:
<telerik:RadWindow ID="RadWindow1" runat="server" AutoSize="true" OnClientAutoSizeEnd="OnClientAutoSizeEnd">
</telerik:RadWindow>
<script type="text/javascript">
    function OnClientAutoSizeEnd(wnd) {
        wnd.set_autoSize(false);
    }
</script>


Regards,
Marin Bratanov
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Window
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Answers by
Marin Bratanov
Telerik team
Share this question
or