Article relates to
RadWindow for ASP.NET AJAX
Marin Bratanov, Telerik
5th of January 2012
Set the size of a RadWindow
supports its size in pixels only, as does any other window, e.g. in the operating system - changing the screen resolution or adding other elements in the viewport do not change the dimensions of the already existing windows. Therefore the RadWindow
has the same behavior.
You can use a combination of the RadWIndow's client-side API
and jQuery to calculate the needed dimensions in pixels from the available viewport and set them to the RadWindow. You should also handle the window.resize event in order to recalculate the size when the browser size changes:
get the viewport size:
browserWidth = $telerik.$(window).width();
browserHeight = $telerik.$(window).height();
change the RadWindow size where value is the size in percent you need:
oWnd.setSize(Math.ceil(browserWidth * value / 100), Math.ceil(browserHeight * value / 100));
You can then center the RadWindow:
This can be encapsulated in a function that will be called after the browser is resized. Note how the timeout is used to ensure that the handler is called only once, because older browsers throw the window.resize event numerous times which may result in poor performance without such an insurance:
TO = setTimeout(sizeWindowInPercentage, 100);
A simple page that shows the approach in action is attached to this post as well. Inside there are comments that explain in greater detail what the code does. This can be used as base for further extending this scenario, but you should keep in mind that it has its limitations - e.g. it cannot work for a restriction zone as you cannot handle the zone's size change, there is simply no such event.
to rate this article.