Search code examples
.netasp.nettelerikradwindow

RadWindow Standardization


I'm trying to make sense of the RadWindow/RadWindowManager relation. I see that there can be many RadWindowManager controls defined in one page (unlike the RadScriptManager/ScriptManager which requires one implementation). But I also see that we can implement the RadWindow either inside of the RadWindowManager or as a standalone control.

What is the advantages of using the RadWindowManager beside being able to apply settings defined on the manager to the window? Is it better to keep the RadWindowManager outside of the master page and define it where it is needed, or is it better to keep a global radwindowmanager, and have radwindow as a standalone control?

Thanks.


Solution

  • Using RadWindowManager is simply a convenient way to declare common properties for multiple windows on your page. You can declare multiple RadWindow controls within a RadWindowManager, then access the collection of windows via the following functions:

    var windowManager = $find('<%= MyRadWindowManager.ClientID %>'),
        windows = windowManager.get_windows(),
        wnd,
        i = 0;
    for (; i < windows.length; i++) {
        wnd = windows[i];
        // do something with the RadWindow object
    }
    

    Be careful not to call the RadWindow variable "window", as it would conflict with the global window object.

    If you want a specific RadWindow object, you can use the following code:

    var windowManager = $find('<%= MyRadWindowManager.ClientID %>'),
        wnd = windowManager.getWindowByName("MyWindow");
    // do something with the RadWindow object
    

    Or, what I prefer is to define a single RadWindowManager in my Master page, with no windows defined, and then simply use it to open windows dynamically as needed. Here's an example:

    <telerik:RadWindowManager ID="MasterWindowManager" runat="server" 
        VisibleOnPageLoad="false"
        VisibleStatusbar="false" 
        Behaviors="Close, Move" 
        DestroyOnClose="true" >
    </telerik:RadWindowManager>
    

    Defining a RadWindowManager on your Page will add a radopen function to the global window object. You can use it to dynamically open new RadWindows as needed...

    var showCustomerDetails = function (customerId) {
        var url = String.format("/Views/CustomerDetails.aspx?cid={0}", customerId),
            wnd = window.radopen(url);
        wnd.set_modal(true);
        wnd.setSize(600, 400);
        wnd.show();
        wnd.center();
    }
    

    I hope that helps.