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

Dynamically creating configurable RadWindows (clientside)

5 Answers 116 Views
Window
This is a migrated thread and some comments may be shown as answers.
KracsNZ
Top achievements
Rank 1
KracsNZ asked on 11 Sep 2008, 03:54 AM
Is there a way to create new radwindows from the clientside via javascript so they are configured before being displayed?

I want to set their behaviour and size and position based on whats been passed to the javascript function that creates the window before it gets displayed.

Whenever I call the radopen or radwindow.open functions it displays the window before I can configure it which results in some ugly post-display changes.

This is what I currently have...

// retrieve the radwindowmanager for the page  
var oManager = null;  
 
 
function mainOpenWindow(name, url, winid, buttons, tabs, width, height, left, top, pinned) {  
    /* 
    This function dynamically creates a new rad window configured in a curtain way
    url: target url for inner window
    winid: id for the window
    buttons: what buttons to display
    tabs: 0 = use tabs, 1 = use new window
    width, height, left, top: window position
    pinned: is window pinned
    */ 
    if (!oManager) oManager = GetRadWindowManager();  
 
    var oWindow = oManager.open(url, null);  
    oWindow.set_behaviors(buttons);  

Is there a way for me to create a new radwindow, set its properties, attach it to the radwindowmanager and then display it?

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 11 Sep 2008, 12:26 PM
Hello Mark,

When you use radopen() or GetRadWindowManager().open(), RadWindow is created but it is shown immediatley - you can make changes in its behavior, but these actions will be visible
What I can suggest is to have a RadWindow declared on the page - this way you can access it with the ASP.NET AJAX $find(). From this point on you can set various properties by using RadWindow's client-side API and to show it after that with the show() method.


Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
KracsNZ
Top achievements
Rank 1
answered on 12 Sep 2008, 03:00 AM
I can't set it in the form because I have no idea which (and how many) windows will be opened by the client.

It would be great if you guys could consider a client side option to do this for a future release. i.e. just add some parameters to the RadOpen and RadWindowManager.Open to either accept behaviours or to start invisible.

Cheers.
0
Georgi Tunev
Telerik team
answered on 12 Sep 2008, 12:06 PM
Hi Mark,

In general you can achieve this by using the fact that RadWindowManager is yet another RadWindow. We don't recommend using this approach, but if you need, you can try it like this:

function createWin() 
    var manager = $find("<%= RadWindowManager1.ClientID %>");  
    var newWnd = manager.clone("NewWndName"); 
    newWnd.setUrl("http://www.google.com");  
    newWnd.show(); 



All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
KracsNZ
Top achievements
Rank 1
answered on 15 Sep 2008, 10:05 PM
I tried creating a hidden template window and cloning that, but it wasn't even available to clone with visible set to false.

Just curious why you said not to clone the RadWindowManager?

Cheers.
0
Georgi Tunev
Telerik team
answered on 16 Sep 2008, 11:54 AM
Hi Mark,

Basically, RadWindow is opened in 2 ways - as a server object (VisibleOnPageLoad=true) or with radopen / show that are RadWindowManager's client-side methods. These ways ensure that the window object will be properly initialized and behaves as expected while there are possible side-effects when cloning the manager.

By the way, Visible=false set to any control (not just RadWindowManager/RadWindow) will not render the control in the page - that is why you were not able to clone the manager.


Greetings,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
KracsNZ
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
KracsNZ
Top achievements
Rank 1
Share this question
or