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

oWindow.setSize Error On FIreFox :-(

10 Answers 136 Views
Window
This is a migrated thread and some comments may be shown as answers.
barbod
Top achievements
Rank 1
barbod asked on 22 May 2011, 08:04 AM

Hi

i use Following code : (RadControls for ASP.NET Q3 2010)


                var oWindow = window.radopen(navigateUrl, null);
                oWindow.setSize(winWidth, winHeight);
                oWindow.set_title(winTitle);
                oWindow.add_pageLoad(function () { oWindow.set_status(" "); });
                oWindow.center();

and config of RadWindowManager :

            <telerik:RadWindowManager ID="RadWindowManager" runat="server"
                Skin="Vista" Behavior="Close, Move, Resize, Minimize, Maximize, Reload"
                OnClientClose="OnClientClose" Width="1280px" Height="1024px"
                VisibleStatusbar="true" RestrictionZoneID="fullheightcontainer"
                ShowContentDuringLoad="true" DestroyOnClose="true" MinimizeZoneID="MinimizeBar">
            </telerik:RadWindowManager>

this code work correctly on IE but when i use it in firefox , oWindow.setSize doesn't work
and show all window in Width="1280px" Height="1024px" resolution!!!!


==============================================================================

also i have a question about following script :

// Get instance from Parent RadWindowManager
function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow)
        oWindow = window.radWindow;
    else if (window.frameElement.radWindow)
        oWindow = window.frameElement.radWindow;
    return oWindow;
}

function ShowModalWindow(navigateUrl, winWidth, winHeight, winTitle, setModal) {

    var oManager = GetRadWindow().get_windowManager();
    var oWindow = oManager.open(navigateUrl, null);

    // Set RadWindow Behaviors ClientSide
    // Close, Move, Resize, Reload
    oWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close +
                            Telerik.Web.UI.WindowBehaviors.Move +
                            Telerik.Web.UI.WindowBehaviors.Resize +
                            Telerik.Web.UI.WindowBehaviors.Reload);

    oWindow.setSize(winWidth, winHeight);
    oWindow.set_title(winTitle);
    oWindow.add_pageLoad(function () { oWindow.set_status(" "); });
    oWindow.center();
    if (setModal == true) {
        oWindow.set_modal(true);
    }
    return false;
};

when i using this code i have an error :
"Microsoft JScript runtime error: 'Telerik.Web.UI.WindowBehaviors.Close' is null or not an object" :-(


how can i fix it , please help me
really thanks

10 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 24 May 2011, 01:12 PM

Hello Barbod,

This behavior is by design and is observed in IE, as well as Firefox - in the invalid scenario when the RadWIndow's original size is larger than the available size of the Restriction Zone we cannot predict what the desired behavior should be - should the RadWIndow take up the whole zone, should it get the default size, or should it get a different size? This is the reason we have left this responsibility to the developer - only the he/she would know the size of the zone and should adjust the RadWindow to match his/her custom needs accordingly.

What I would suggest is to remove the explicit Height and Width settings from the RadWindowManager declaration and use the client-side API to control the size entirely (or to set them to values that are lower than the size of the Restriction Zone).

As for the behaviors - it seems that you are trying to set the behaviors of a new RadWindow in the context of a content page that does not have a RadWindow or RadWindowManager defined in it and thus this enumerator is not available there, since the RadWindow classes are not loaded. To work around that you can either move the opener function to the main page and call it via the BrowserWindow property of the RadWindow, or add a blank RadWindowManager to the content page. You can also use the integer equivalent of the enumerator to set the behaviors (You can see it in the WindowBehaviors.cs file):

  • None = 0
  • Resize = 1
  • Minimize = 2
  • Close = 4
  • Pin = 8
  • Maximize = 16
  • Move = 32
  • Reload = 40

On a side note - when opening a RadWindow from within a RadWindow I would recommend enclosing the opener function in a setTimeout() function with a timeout of 0 milliseconds to allow the browser to complete all calculations and properly set the focus to the new RadWindow.

For your reference I am attaching my test page with some of the suggested modifications applied.



All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
barbod
Top achievements
Rank 1
answered on 25 May 2011, 10:10 AM
hi , really thanks
but i have another question!!!
i read a document about RadWindowManager on your site :
http://www.telerik.com/help/aspnet-ajax/window-programming-opening-from-within-dialog.html

my solution (WebTop or WeDesktop) :
1) simple web form that contains RadWindowManager (User Desktop like windows)
2) icon on simple page that can open URL with RadWindowManager Control 
    (web page that like windows open on desktop)
3) in opend RadWindow i haven't RadWindowManager and by use your code in this link
    i can open modal window on pranet! (for insert/update) now , 
    when i want to refresh parent window with opend modal , cause i open modal with code , 
    i can't reload parent. 
    i know the problem (cause i use desktop RadWindowManager  and it is Modal Parent)
    how can i find which window call modal with code , and refresh it , without refresh desktop!!!
4) i didn't use RadWindowManager on open window , cause it's light and run faster!!!
5) i want open radwindow just with javascript code.

please help me
Best Regards
0
Marin Bratanov
Telerik team
answered on 26 May 2011, 12:15 PM

Hello Barbod,

I am not sure I understand your scenario completely, but I think that storing in a global variable a reference to the first RadWindow will enable you to later access it (either from the main form, or from a RadWindow via its BrowserWindow property) so that you can modify it at any time. For example you could call a function defined in it that reloads the desired content. How to do that is described in the following help article: http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html.

You can also use the RadWIndowManager's getWindowByName() method to get a reference to the first window by its ID.

Please note that our support system is focused on providing workarounds for bugs and controls' incompliances and we do not develop custom solutions. We have uploaded a lot of online demos which cover the functionality of the controls and they should be enough to let the developer extend them further in order to implement the desired scenario. I recommend to examine this online demo which is very similar to your requirement. When you install RadControls, our online examples projects are automatically installed on your computer and you can not only examine their full source code, but also extend them further in order to meet your requirements.

You can open the demos from here:

Start\Programs\Telerik\RadControls for ASPNET AJAX\Open Sample WebSite In VisualStudio

The actual location on your hard disk is the following one:

C:\Program Files\Telerik\RadControls for ASPNET AJAX\Live Demos

Please try to implement the scenario based on the provided demo. In case you experience problems please open a support ticket and send me a small sample application where your issue can be reproduced - I will check it right away.



Best wishes,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
LeBear
Top achievements
Rank 1
answered on 04 Aug 2011, 05:47 PM
I strongly request a re-examination of this behavior.

I have a scenario where I have set the optimal size for a radWindow, but then resize the window when it's opened if it's too large or positioned to go outside of the restrictionZone.  However, if the original size/position isn't valid, I can't fix it.

All I'm asking for is that you make the setSize work even if the original size wasn't valid.

Thank you.
0
Marin Bratanov
Telerik team
answered on 05 Aug 2011, 03:14 PM
Hello Barry,


I see that you are using a version of our controls that is almost three years old. Please note that there have been many improvements during this time and I would suggest that you upgrade to the latest version to take advantage of them, as some of them are exactly in the RestrictionZone functionality.

That being said - this behavior is by design - if the RadWindow is initially incorrectly placed we cannot move it when the command is to resize it, as this would be a prime example of unexpected, therefore buggy behavior. It is up to the developer to make sure that his/her scenario is initially correct and does not contradict itself (i.e. trying to confine a RadWindow in a certain zone, yet defining a size that would not fit in that zone).

  What I can recommend to work around this is that you try to validate the scenario- i.e. force the RadWindow in the zone by mazimizing it and setting the offset from the zone as well, then you can try to force it to resize again. This managed to get resizing working fine with me in the following invalid scenario:
<telerik:RadWindow runat="server" ID="RadWindow1" RestrictionZoneID="zone1" Width="1000px" 
    Height="700px" VisibleOnPageLoad="true" Top="0px" Left="0px">
</telerik:RadWindow>
<asp:Button ID="Button1" Text="set the size" runat="server" OnClientClick="setTheSize(); return false;" />
<div id="zone1" style="width: 500px; height: 500px; border: 1px solid black;">
</div>

function setTheSize()
        {
            var oWnd = $find("RadWindow1");
            //these two line try to get the scenario as correct as possible
            oWnd.maximize();
            oWnd.restore();
  
            //this tries to position the RadWindow in the top left corner of the restriction zone
            oWnd.moveTo(0, 0);
  
            //hack the resizing
            setTimeout(function ()
            {
                oWnd.setSize(300, 300);
            }, 0);
            setTimeout(function ()
            {
                oWnd.set_width(300);
            }, 0);
            setTimeout(function ()
            {
                oWnd.set_height(300);
            }, 0);
            setTimeout(function ()
            {
                oWnd.center();
            }, 0);
  
        }

Please note that this is actually hacking the functionality and is very likely to work in a very limited number of scenarios, therefore I would recommend that you design yours to be initially correct.

Kind regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
LeBear
Top achievements
Rank 1
answered on 05 Aug 2011, 05:06 PM
I'm actually using the latest version. (I have separate accounts for participation and for managing our licenses.)
I also did a workaround for this.  I'm implementing a "desktop" UI, and I wanted to setup the windows to an initial/optimal size, but if the users had set their window smaller, then "unexpected" results would, indeed, occur.

I actually did stumble on to a similar workaround.  I'm using the timeout, maximizing, restoring, moving, etc. functions, and I'm also saving the window size and position to a cookie so that when the user opens the windows again, their previous/preferred size/position is preserved.  But, since it's not hard-coded into the windows, I also do some tricks by moving it to 0,0, resizing it, and moving it to the ultimate location.  If any of those commands fail due to exceeding the bounds of the restriction zone, then they just don't execute and the window remains where it is.

I also tap into the window resize event and do a similar function to force the window to fit into the resulting space.  There's a lower limit where the window can get too small, but this is actually working pretty well.

I would have preferred to allow for a hard-coded initial size, but I can understand this situation and deal with it. I don't want to run into some situations where it might not work.

Thanks.
0
LeBear
Top achievements
Rank 1
answered on 10 Aug 2011, 06:38 PM
Ok, so I was wrestling with this quite a bit.  I'd get close, then run into cross-browser issues and lose ground.

My final solution seems to do the trick.  Anything you can see that would cause a problem here?

oWindow.set_restrictionZoneID(null);
oWindow.setSize(oWidth, oHeight);
oWindow.moveTo(oLeft, oTop);
oWindow.set_restrictionZoneID('RestrictionZone');

In this scenario, I'm calculating oLeft, oTop, oWidth, and oHeight to what I need whenever the window is opened or the browser is resized.  I remove the window from the restriction zone (set the zone to null), move and resize the window, and then re-establish the restriction zone.

Preliminary testing shows this to work!
0
Marin Bratanov
Telerik team
answered on 12 Aug 2011, 11:30 AM
Hello Barry,

  If you calculate the dimensions and position properly there should be no issues with this approach. I also think that you could remove the RestrictionZoneID property from the markup, as you would inevitably set it via JavaScript, thus you would save one calculation.


Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
LeBear
Top achievements
Rank 1
answered on 12 Aug 2011, 03:55 PM
Good Point Marin,

Since I always set that upon opening the window, there is no reason to have it set declaratively.  I've removed that, and all is well. 

Thanks.
0
Tom
Top achievements
Rank 1
answered on 16 Jan 2014, 06:36 PM
Thanks to LeBear for the tip on removing and then reassigning the restriction zone. This is the perfect solution in my situation. I am using a RadPane as the restriction zone. When resizing, I was having problems with the RadWindows not always being resized properly until I wrapped the moveTo and set_height/set_width inside the restriction zone removal/reassignment. Just as LeBear did:

// get location of restriction zone container within browser
var rpMRight = document.getElementById("<%= rpMRight.ClientID %>");
var rpMRightUl = rpMRight.getBoundingClientRect();
// remove restriction zone from RadWindow
oWnd.set_restrictionZoneID(null);
// move first (add offset so RadWindow ends up in the restriction zone), then resize RadWindow
// note that radWin values were previously calculated and are relative to the restriction zone
oWnd.moveTo(rpMRightUl.left + radWin.left, rpMRightUl.top + radWin.top);
oWnd.set_width(radWin.width);
oWnd.set_height(radWin.height);
// reconnect restriction zone
oWnd.set_restrictionZoneID("<%= rpMRight.ClientID %>");
Tags
Window
Asked by
barbod
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
barbod
Top achievements
Rank 1
LeBear
Top achievements
Rank 1
Tom
Top achievements
Rank 1
Share this question
or