Domanda

Sto cercando di dare un senso alla relazione Radwindow / RadwindowManager.Vedo che ci possono essere molti controlli RadwindowManager definiti in una pagina (a differenza del RadscriptManager / ScriptManager che richiede un'implementazione).Ma vedo anche che possiamo implementare il Radwindow all'interno del RadwindowManager o come controllo standalone.

Quali sono i vantaggi dell'utilizzo del RadwindowManager accanto a essere in grado di applicare le impostazioni definite sul gestore alla finestra?È meglio mantenere il RadwindowManager al di fuori della pagina Master e definirlo dove è necessario, o è meglio mantenere un Global RadwindowManager e avere Radwindow come controllo autonomo?

Grazie.

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top