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

Javascript Resize of RadWindow

10 Answers 510 Views
Window
This is a migrated thread and some comments may be shown as answers.
Pat
Top achievements
Rank 1
Pat asked on 04 Oct 2007, 06:35 PM
With the previous version of the RadWindow (RadControls for ASP.Net Q1 2007), there was a method called GetWindowByName in the radwindowmanager.  It seems this function is no longer available in the prometheus tools.  With that in mind, how do I go about still using a javascript function to resize the radwindow?  The code I used is listed below:

    function ResizeWindow(WinName)     
    {     
        var rwManager = GetRadWindowManager();     
        var rwindow = rwManager.GetWindowByName(WinName);     
        var screenHeight = document.documentElement.clientHeight;  
        var screenWidth = document.documentElement.clientWidth;  
        rwindow.SetHeight(parseInt(screenHeight - 150));   
        rwindow.SetWidth(parseInt(screenWidth - 150));  
        rwindow.Center();  
    }    


Thanks!
Pat.

10 Answers, 1 is accepted

Sort by
0
Shaun Peet
Top achievements
Rank 2
answered on 05 Oct 2007, 02:10 AM
Hello Pat,

The Prometheus controls help section is a good place to start:

http://www.telerik.com/help/radcontrols/prometheus/

Most functions have been renamed to more closely (but not always fully) comply with the ASP.NET AJAX naming conventions.  The GetWindowByName is now getWindowByName.

SetHeight is now set_Height, and GetHeight is now get_Height.

Hope that helps,

Shaun
0
Pat
Top achievements
Rank 1
answered on 05 Oct 2007, 03:11 AM
Thanks for the reply.

Is there a GetRadWindowManager anymore?  I can't seem to find a reference for it. 

Thanks!
Pat.
0
Tervel
Telerik team
answered on 05 Oct 2007, 11:14 AM
Hello Pat,

Yes, the method GetRadWindowManager  still exists for backward compatibility.

However, we encourage and expect users of the Prometheus suite to make use of the standard MS AJAX way of referencing client controls using the $find method.

You can use this method to look up both RadWindow and RadWindowManager objects.

So, if you had a RadWindowManager with ID="Manager1", you could use the following code:

<script>
var manager = $find("<%=Manager1.ClientID%>");
</script>

Sincerely yours,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Pat
Top achievements
Rank 1
answered on 05 Oct 2007, 01:20 PM
I'm trying to use the $find("<%=Manager1.ClientID%>"); as you had stated but I am just getting a null returned.
0
Georgi Tunev
Telerik team
answered on 05 Oct 2007, 02:43 PM
Hello Pat,

We are not quite sure what exactly is the problem, as this is a standard ASP.NET AJAX method. Can you please open a new ticket and send us your page so we can check it?

Thank you in advance for your cooperation.



Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Pat
Top achievements
Rank 1
answered on 05 Oct 2007, 03:14 PM
I'll try to open up a ticket but not sure I have the credentials for it since I am on contract with the client.  But in the mean time, here is the page.  It is a master page but that shouldn't make any difference.  Thanks!

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Default.master.cs" Inherits="DefaultMaster" 
    EnableViewState="true" %> 
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register Assembly="RadToolbar.Net2" Namespace="Telerik.WebControls" TagPrefix="radTlb" %> 
<%@ Register Assembly="RadSplitter.Net2" Namespace="Telerik.WebControls" TagPrefix="radspl" %> 
<%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %> 
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %> 
<%@ Register Assembly="RadPanelbar.Net2" Namespace="Telerik.WebControls" TagPrefix="radP" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head" runat="server">  
    <title /> 
    <script type="text/javascript">  
    var toggleActions="";  
    function SaveCookieOnToggle(node)  
    {  
        toggleActions += node.Value + '*';  
        createCookie('TreeToggleActions',toggleActions,1);  
    }  
    function createCookie(name,value,days)  
    {  
        if (days)  
        {  
            var date = new Date();  
            date.setTime(date.getTime()+(days*24*60*60*1000));  
            var expires = "; expires="+date.toGMTString();  
        }  
        else  
        {  
            var expires = "";  
        }  
        document.cookie = name+"="+value+expires+"; path=/";  
    }  
    function ToggleNode(node)  
    {  
        node.Toggle();  
    }  
    </script> 
</head> 
<body> 
    <script> 
    function ResizeWindow(WinName)     
    {    
        var rwManager = $find("<%=RadWindowManager1.ClientID%>");  
        var rwindow = rwManager.getWindowByName(WinName);     
        var screenHeight = document.documentElement.clientHeight;  
        var screenWidth = document.documentElement.clientWidth;  
        rwindow.set_Height(parseInt(screenHeight - 150));   
        rwindow.set_Width(parseInt(screenWidth - 150));  
        rwindow.center();  
    }     
    </script> 
    <form id="mainForm" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        &nbsp;  
        <asp:SiteMapDataSource ID="modulesSource" runat="server" SiteMapProvider="DefaultSiteMapProvider" 
            ShowStartingNode="False" /> 
        <asp:SiteMapDataSource ID="moduleActionsSource" runat="server" SiteMapProvider="DefaultSiteMapProvider" 
            ShowStartingNode="False" StartingNodeOffset="1" /> 
        &nbsp;  
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server" EnableViewState="true" 
            OnLoadDockLayout="LoadDockingLayout" OnSaveDockLayout="SaveDockingLayout" StoreLayoutInViewState="false" 
            Skin="WebBlue">  
            <div id="mainwrapper">  
                <div id="header">  
                    <i>on</i>Board®</div> 
                <div id="module-container">  
                    <table width="100%">  
                        <tr> 
                            <td align="left">  
                                <asp:Menu SkinID="modulesMenu" DataSourceID="modulesSource" runat="server" ID="ModulesMenu">  
                                    <StaticItemTemplate> 
                                        <asp:HyperLink ID="HyperLink1" CssClass="moduleName" NavigateUrl='<%# ((MenuItem)Container.DataItem).NavigateUrl %>' 
                                            Text='<%# ((MenuItem)Container.DataItem).Text %>' runat="server" /> 
                                    </StaticItemTemplate> 
                                </asp:Menu> 
                            </td> 
                            <td align="right">  
                                <asp:UpdatePanel runat="server" ID="ToolbarUpdatePanel">  
                                    <ContentTemplate> 
                                        <radTlb:RadToolbar ID="MainToolbar" runat="server" AutoPostBack="true" UseFadeEffect="True" 
                                            Skin="WebBlue" ImagesDir="../App_Themes/Default/Images/" OnOnClick="MainToolbar_OnClick" 
                                            DisplayEnds="false">  
                                            <Items> 
                                                <radTlb:RadToolbarButton ID="buttonReports" ToolTip="Reports" CommandName="reports" 
                                                    ButtonText="Reports" ButtonImage="report.png" /> 
                                                <radTlb:RadToolbarButton ID="buttonInquiry" ToolTip="Inquiry" CommandName="inquiry" 
                                                    ButtonText="Inquiry" ButtonImage="computer_link.png" /> 
                                                <radTlb:RadToolbarButton ID="buttonSearch" ToolTip="Search" CommandName="search" 
                                                    ButtonText="Search" ButtonImage="magnifier.png" /> 
                                                <radTlb:RadToolbarButton ID="buttonPasswordChange" ToolTip="Password Change" CommandName="passwordchange" 
                                                    ButtonText="Password Change" ButtonImage="application_key.png" /> 
                                            </Items> 
                                        </radTlb:RadToolbar> 
                                        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
                                            <Windows> 
                                                <telerik:RadWindow ID="ExternalLinkInquiry" runat="server" Modal="true" NavigateUrl="~/ExternalLinkInquiry.aspx" 
                                                    OnClientShow="ResizeWindow('ExternalLinkInquiry')" DestroyOnClose="false" /> 
                                                <telerik:RadWindow ID="ExternalLinkReports" runat="server" Modal="true" NavigateUrl="~/ExternalLinkReports.aspx" 
                                                    OnClientShow="ResizeWindow('ExternalLinkReports')" DestroyOnClose="false"/>  
                                                <telerik:RadWindow ID="ExternalLinkSearch" runat="server" Modal="true" NavigateUrl="~/ExternalLinkSearch.aspx" 
                                                    OnClientShow="ResizeWindow('ExternalLinkSearch')" DestroyOnClose="false" /> 
                                            </Windows> 
                                        </telerik:RadWindowManager> 
                                    </ContentTemplate> 
                                </asp:UpdatePanel> 
                            </td> 
                        </tr> 
                    </table> 
                </div> 
                <radspl:RadSplitter runat="Server" ID="MasterSplitter" Skin="WebBlue" Width="100%" 
                    Height="100%" HeightOffset="100" BackColor="White">  
                    <radspl:RadPane ID="NavigationPane" runat="server" Width="200px" Height="100%" Scrolling="None">  
                        <telerik:RadDockZone ID="RadDockingZone1" runat="server" Skin="WebBlue" Orientation="vertical" 
                            BorderWidth="0px">  
                            <telerik:RadDock ID="RadDockNavigation" Title="Navigation" runat="server" Skin="WebBlue" 
                                DockMode="Docked" Width="200px" AutoPostBack="true">  
                                <Commands> 
                                    <telerik:DockPinUnpinCommand /> 
                                    <telerik:DockExpandCollapseCommand /> 
                                </Commands> 
                                <ContentTemplate> 
                                    <radT:RadTreeView ID="NavigationTreeView" runat="server" Skin="WebBlue" DataSourceID="moduleActionsSource" 
                                        AfterClientClick="SaveCookieOnToggle" BeforeClientClick="ToggleNode" /> 
                                </ContentTemplate> 
                            </telerik:RadDock> 
                            <telerik:RadDock ID="RadDockMessages" Title="Messages" runat="server" Skin="WebBlue" 
                                Width="200px" DockMode="Docked" AutoPostBack="true">  
                                <Commands> 
                                    <telerik:DockExpandCollapseCommand /> 
                                </Commands> 
                                <ContentTemplate> 
                                    <asp:UpdatePanel runat="server" ID="UpdatePanelStatusMessages">  
                                        <ContentTemplate> 
                                            <radT:RadTreeView ID="StatusMessagesTreeView" runat="server" Skin="WebBlue" AfterClientClick="SaveCookieOnToggle" 
                                                BeforeClientClick="ToggleNode" ExpandDelay="0" Width="100%" /> 
                                        </ContentTemplate> 
                                    </asp:UpdatePanel> 
                                </ContentTemplate> 
                            </telerik:RadDock> 
                        </telerik:RadDockZone> 
                    </radspl:RadPane> 
                    <radspl:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="forward" /> 
                    <radspl:RadPane ID="ContentPane" runat="server" Scrolling="None" Height="100%">  
                        <div id="breadcrumb">  
                            <asp:SiteMapPath ID="DefaultBreadCrumb" SiteMapProvider="DefaultSiteMapProvider" 
                                runat="server" /> 
                        </div> 
                        <telerik:RadDockZone ID="RadDockingZone2" runat="server" Skin="WebBlue" Orientation="horizontal" 
                            Width="99%" BorderWidth="0px">  
                            <telerik:RadDock ID="RadDockContent" runat="server" Width="100%" Skin="WebBlue" AutoPostBack="true">  
                                <Commands> 
                                    <telerik:DockPinUnpinCommand /> 
                                    <telerik:DockExpandCollapseCommand /> 
                                </Commands> 
                                <ContentTemplate> 
                                    <asp:UpdatePanel ID="UpdatePanelDefaultContent" runat="server">  
                                        <ContentTemplate> 
                                            <asp:ContentPlaceHolder ID="DefaultContent" runat="server">  
                                            </asp:ContentPlaceHolder> 
                                        </ContentTemplate> 
                                    </asp:UpdatePanel> 
                                </ContentTemplate> 
                            </telerik:RadDock> 
                        </telerik:RadDockZone> 
                    </radspl:RadPane> 
                </radspl:RadSplitter> 
                <div id="footer">  
                    <table width="100%">  
                        <tr> 
                            <td style="font-family: Verdana; font-size: 8pt">  
                                <asp:LoginStatus runat="server" ID="LoginStatus" CssClass="loginStatusLink" LogoutAction="Redirect" 
                                    LogoutPageUrl="~/Default.aspx" /> 
                            </td> 
                        </tr> 
                    </table> 
                </div> 
            </div> 
            <asp:SiteMapDataSource ID="ApplicationSiteMap" runat="server" SiteMapProvider="DefaultSiteMapProvider" 
                ShowStartingNode="False" /> 
            <div id="Div1">  
                <table width="100%">  
                    <tr> 
                        <td style="width: 50%; height: 21px;">  
                            <div id="copyright">  
                                Â© 2007 Jack Henry & Associates</div> 
                        </td> 
                        <td style="width: 50%; height: 21px;">  
                            <div id="buildversion">  
                                Build:  
                                <asp:Label runat="server" ID="AppVersion" /></div>  
                        </td> 
                    </tr> 
                </table> 
            </div> 
            &nbsp;  
            <table width="100%">  
                <tr> 
                    <td align="left" colspan="2">  
                        <telerik:RadDockZone ID="RadDockingZone3" runat="server" Skin="WebBlue" Orientation="horizontal" 
                            Width="99%" BorderWidth="0px">  
                        </telerik:RadDockZone> 
                    </td> 
                </tr> 
            </table> 
            <div style="display: none">  
                <asp:UpdatePanel runat="server" ID="UpdatePanelHidden">  
                    <Triggers> 
                        <asp:AsyncPostBackTrigger ControlID="RadDockNavigation" EventName="DockPositionChanged" /> 
                        <asp:AsyncPostBackTrigger ControlID="RadDockContent" EventName="DockPositionChanged" /> 
                        <asp:AsyncPostBackTrigger ControlID="RadDockMessages" EventName="DockPositionChanged" /> 
                    </Triggers> 
                </asp:UpdatePanel> 
            </div> 
        </telerik:RadDockLayout> 
    </form> 
</body> 
</html> 
 
0
Georgi Tunev
Telerik team
answered on 08 Oct 2007, 02:20 PM
Hello Pat,

Thank you for the code - I see what the problem is.

The OnClientShow property sets the name of the function that will be called - it does not call the function itself. As you've set it: OnClientShow="ResizeWindow('ExternalLinkInquiry')", here is what you will get in the Html:

Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadWindow, {"ClientStateFieldID":"ctl00_ExternalLinkInquiry_ClientState","FormID":"aspnetForm","Left":"","Modal":true,"Name":"ExternalLinkInquiry","NavigateUrl":"../ExternalLinkInquiry.aspx","Skin":"","Top":""}, {"Show":ResizeWindow('ExternalLinkInquiry')}, null, $get("ctl00_ExternalLinkInquiry"));
});


e.g. you will call the ResizeWindow function before the RadWindow / RadWindowManager is fully rendered on the page - that is why you are getting an error.

Please set only the function's name in the OnClientShow property and code your function so different code is executed depending on which RadWindow is shown .


Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Pat
Top achievements
Rank 1
answered on 09 Oct 2007, 05:32 PM
I still end up with an error.

The function to get the RadWindowManager is returning a null even though it exists in the page. 

The function in the OnClientShow is only fired when the window is opened from a button click in the main toolbar.  So I don't think it is an instantiation issue.

It seems that the function of GetRadWindowManger is failing to find the manager even though it is fully defined and named properly.

pat.
0
Pat
Top achievements
Rank 1
answered on 09 Oct 2007, 05:36 PM
Actually It isn't the GetRadWindowManager but the $find isn't locating the manager.  The screen is fully rendered and the radwindow is opened from a button click event.  So needless to say, I'm at a total loss as to what is going on or how to fix.
0
Georgi Tunev
Telerik team
answered on 10 Oct 2007, 11:13 AM
Hi Pat,

The OnClientShow property must be set like this: OnClientShow="ResizeWindow"

Since I don't have your full project, I've had to disable some of your code in order to run the page. For your convenience I've attached to this thread a small movie that shows part of my testings on your case - as you can see, everything is working as expected and the RadWindowManager can be found by using $find() method.

If you still experience problems, please open a ticket and send me a full, working project where they can be reproduced. I will check the project and do my best to help.



All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
Pat
Top achievements
Rank 1
Answers by
Shaun Peet
Top achievements
Rank 2
Pat
Top achievements
Rank 1
Tervel
Telerik team
Georgi Tunev
Telerik team
Share this question
or