开发者

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开发者_如何学JAVA 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.


I just answered your forum thread in Telerik's forums, but for convenience I am pasting my reply below, as an addition to Kevin's reply.

Basically, the idea behind the RadWindowManager is to allow the users to create on the client multiple RadWindows with pre-defined properties, set in the manager. The manager's client-side API allows the developer to easily get a reference to such RadWindows and to operate with them. There are a couple of things however, that should be kept in mind when using RadWindowManager.

1.. In case you have multiple RadWindowManagers on the same page:

 All RadWindowManager's functions (radopen, radalert, radconfirm, radprompt, GetRadWindowManager, etc) are always using the first rendered RadWindowManager on the page.
 Every RadWindowManager "knows" only the RadWindows that are declared in its Windows collection.

This means that if you have a RadWindow2 as a standalone control OR declared in RadWindowManager2, and you use something like radopen(myUrl, "RadWindow2");, radopen will use RadWindowManager1 and will open a new RadWindow with the settings taken from RadWindowManager1. To avoid that problem, when you have multiple managers on a page, you need to get a reference to the correct RadWindowManager first and then call its methods. e.g. var manager = $find("<%= RadWindowManager2.ClientID %>"); manager.open(myUrl, "RadWindow2");

2.. Standalone RadWindow controls cannot be controlled by RadWindowManager - they are separate controls and are not affected by manager's settings.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜