Robert Bross
Top achievements
Rank 1
Robert Bross
asked on 02 Jul 2008, 08:35 PM
I am creating multiple windows in my application. I have a routine that loops through the windows using the get_windows method of the RadWindowManager. Whenever I close a window though, the get_windows method still returns a reference to the closed window in the get_windows method. Is this by design? If so, how do I remove it from the array? I saw something about using the DestroyOnClose method, but that is Server Side. Is there a client side equivalent of this? Thanks!
4 Answers, 1 is accepted
0
Hi Robert,
Indeed, DestroyOnClose is what you need - set it to true in the RadWindowManager's declaration and you should not experience this problem. There is no client-side equivalent.
Greetings,
Georgi Tunev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Indeed, DestroyOnClose is what you need - set it to true in the RadWindowManager's declaration and you should not experience this problem. There is no client-side equivalent.
Greetings,
Georgi Tunev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Robert Bross
Top achievements
Rank 1
answered on 03 Jul 2008, 12:30 PM
Thanks Georgi,
That got me closer to what I am looking for. However, the way that I am using it is that I am attaching an event using the add_close method of a window. When that method is triggered, the windows array still contains the window that it just closed. Is there any way to force the windows array to refresh or is there an "after_close" method that I can tap into for a window? I have created a page that demonstrates this. Notice that when you create a new window and close it, the window reference is still in the array and still gets listed. Thanks Again!
============= Sample Page =========================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestDestroyOnClose.aspx.cs" Inherits="TestDestroyOnClose" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var windowId = 0;
function listWindowIds()
{
var oManager = GetRadWindowManager();
var windows = oManager.get_windows();
document.getElementById("windowIds").innerHTML = "Number of Windows: " + windows.length + "<br>==================================================<br>";
for (var x=0; x<windows.length; x++)
{
document.getElementById("windowIds").innerHTML = document.getElementById("windowIds").innerHTML + windows[x].get_id() + "<br>";
}
}
function openWindow()
{
var oWindow =radopen("http://www.google.com", "W" + windowId++);
oWindow.add_close(listWindowIds);
listWindowIds();
}
</script>
</head>
<body>
<form id="form" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" DestroyOnClose="True">
</telerik:RadWindowManager>
<input type="button" value="New Window" onclick="openWindow();" />
<input type="button" value="Refresh Window Ids" onclick="listWindowIds();" />
<div id="windowIds">
</div>
</div>
</form>
</body>
</html>
That got me closer to what I am looking for. However, the way that I am using it is that I am attaching an event using the add_close method of a window. When that method is triggered, the windows array still contains the window that it just closed. Is there any way to force the windows array to refresh or is there an "after_close" method that I can tap into for a window? I have created a page that demonstrates this. Notice that when you create a new window and close it, the window reference is still in the array and still gets listed. Thanks Again!
============= Sample Page =========================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestDestroyOnClose.aspx.cs" Inherits="TestDestroyOnClose" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var windowId = 0;
function listWindowIds()
{
var oManager = GetRadWindowManager();
var windows = oManager.get_windows();
document.getElementById("windowIds").innerHTML = "Number of Windows: " + windows.length + "<br>==================================================<br>";
for (var x=0; x<windows.length; x++)
{
document.getElementById("windowIds").innerHTML = document.getElementById("windowIds").innerHTML + windows[x].get_id() + "<br>";
}
}
function openWindow()
{
var oWindow =radopen("http://www.google.com", "W" + windowId++);
oWindow.add_close(listWindowIds);
listWindowIds();
}
</script>
</head>
<body>
<form id="form" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" DestroyOnClose="True">
</telerik:RadWindowManager>
<input type="button" value="New Window" onclick="openWindow();" />
<input type="button" value="Refresh Window Ids" onclick="listWindowIds();" />
<div id="windowIds">
</div>
</div>
</form>
</body>
</html>
0
Accepted
Hi Robert,
Thank you for the additional information. Basically, there is a way to remove items from the collection, but I am not quite sure what exactly is your real-world scenario.
You can find below how to check if the RadWindow is closed - I think this approach will be more suitable:
Kind regards,
Georgi Tunev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for the additional information. Basically, there is a way to remove items from the collection, but I am not quite sure what exactly is your real-world scenario.
You can find below how to check if the RadWindow is closed - I think this approach will be more suitable:
function listWindowIds() |
{ |
var oManager = GetRadWindowManager(); |
var windows = oManager.get_windows(); |
document.getElementById("windowIds").innerHTML = "Number of Windows: " + windows.length + "<br>==================================================<br>"; |
for (var x=0; x < windows.length; x++) |
{ |
//TELERIK: Check if the window is closed and if it is, do not use it for any purpose |
if (windows[x].isClosed()) continue; |
document.getElementById("windowIds").innerHTML = document.getElementById("windowIds").innerHTML + windows[x].get_id() + "<br>"; |
} |
} |
Kind regards,
Georgi Tunev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Robert Bross
Top achievements
Rank 1
answered on 08 Jul 2008, 02:16 PM
Yea, that is what I wound up doing. I basically wrote a wrapper for the get_windows function that returns the array minus any windows that "are closed". Works like a charm. Thanks for all your help!