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

How Can I Center a Custom Auto Sized Window

1 Answer 54 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kori
Top achievements
Rank 2
Kori asked on 22 Mar 2012, 07:49 PM
So, here's my scenario - in our app, the content of the window can very likely change, so what I've done is added the following to the pages being opened:

function pageLoad() { fixWindow(); }
 
function fixWindow() {
  // Fix the height to show the buttons in the right place.
  var oWnd = GetRadWindow();
  var contentHeight = $('#mainContent').height();
  var newHeight = contentHeight + 10;
  var windowWidth = oWnd.get_width();
  $('#popupWrapper').height(newHeight);
  $('#popupWrapper').width(windowWidth - 75);
  var windowHeight = newHeight + 105;
  oWnd.set_height(windowHeight + "px");
  // if (oWnd != null) {
      // oWnd.center();
  // }
}

This works great, except that if I then try to center the window every time, the window will remain open after a postback. How can I correct this so that the window gets centred and works normally?

(Side note: We tried using the auto-size, but it never did a great job of keeping the window sized properly).

Thanks,
Kori

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 26 Mar 2012, 09:50 AM
Hello Kori,

Take a look at the following help article which explains the most common reasons for problems with autosizing:  http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-autosize-not-correct.html. See which of the points apply to your case and try employing the suggestions.

As for the behavior you get after calling center() - how are you calling the  fixWindow() function? Is it only on the initial page load, or also after AJAX requests? I have seen similar behavior when center or moveTo() have been called after a postback but the RadWindow is already closed on the client (e.g. via the [x] button). If this is your case you can try adding a check - if(oWnd.isVisible()) oWnd.center();

I tried your code in a simple page and things seem to be working fine with me: http://screencast.com/t/sgpws5Un. I am also attaching my test page here as a reference. Please examine it and see what is the difference in the setup that is causing the problem on your end.


Regards,
Marin
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
Window
Asked by
Kori
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or