I originally posted this as a reply to a year old post.
I have a RadWindowManager with DestroyOnClose='true' but on every postback, even after closing the window theRadWindowManager's Windows collection still contains the window. I do not have VisibleOnPageLoad set. Instead, on every load, I run the following javascript.
This successfully opens all the windows minimized inside a taskbar. The problem is that since closed windows are still in the Windows Collection, they reappear.
I did write some code called "OnClientClose that does successfully delete the window from the windows collection on the client side, but it doesn't persist. That code is below:
This code was added in desperation to try and get the information persisted to the server side. I tried setting EnableViewState to false, but as expected that makes it forget about all Windows in the Windows collection except for ones added during that postback, which means it does forget about closed windows but also forgets about minimized windows.
I am about to add a HiddenField which will contain the ClientIDs of all Windows and then I will use that server side to deduce which windows, if any, were closed. While I am hopeful this will work, I am sure it's not the way it is supposed to work.
Added later! I have implemented the HiddenField solution as follows and it works successfully, but I don't think this is the proper way to achieve my goal.
and in the code behind.
This is all working, but I would pre3fer to know the "correct" way to achieve my goal.
Martin
Suggestions welcomed!!
I have a RadWindowManager with DestroyOnClose='true' but on every postback, even after closing the window theRadWindowManager's Windows collection still contains the window. I do not have VisibleOnPageLoad set. Instead, on every load, I run the following javascript.
function
openPromoteWindows(RadWindowManagerId) {
var
oManager = $find(RadWindowManagerId);
var
oWindows = oManager.GetWindows();
for
(i = 0; i < oWindows.length; i++) {
var
oWindow = oWindows[i];
oWindow.show();
oWindow.Minimize();
oWindow.get_popupElement().style.zIndex = 10000 + i;
}
}
This successfully opens all the windows minimized inside a taskbar. The problem is that since closed windows are still in the Windows Collection, they reappear.
I did write some code called "OnClientClose that does successfully delete the window from the windows collection on the client side, but it doesn't persist. That code is below:
function
rwmPromote_Close(sender, eventargs) {
var
rwm = $find(window[
'rwmPromoteId'
]);
var
oWindows = rwm.GetWindows();
var
i;
for
(i = 0; i < oWindows.length; i++) {
var
oWindow = oWindows[i];
if
(oWindow == sender)
break
;
}
if
(i < oWindows.length) {
rwm._windows.splice(i, 1);
}
}
This code was added in desperation to try and get the information persisted to the server side. I tried setting EnableViewState to false, but as expected that makes it forget about all Windows in the Windows collection except for ones added during that postback, which means it does forget about closed windows but also forgets about minimized windows.
I am about to add a HiddenField which will contain the ClientIDs of all Windows and then I will use that server side to deduce which windows, if any, were closed. While I am hopeful this will work, I am sure it's not the way it is supposed to work.
Added later! I have implemented the HiddenField solution as follows and it works successfully, but I don't think this is the proper way to achieve my goal.
function
rwmPromote_Close(sender, eventargs) {
var
rwm = $find(window[
'rwmPromoteId'
]);
var
hf = $get(window[
'hfWindowIdsId'
]);
hf.value =
''
;
var
oWindows = rwm.GetWindows();
var
i;
for
(i = 0; i < oWindows.length; i++) {
var
oWindow = oWindows[i];
if
(oWindow == sender)
break
;
}
if
(i < oWindows.length) {
rwm._windows.splice(i, 1);
oWindows = rwm.GetWindows();
for
(i = 0; i < oWindows.length; i++) {
hf.value += oWindows[i].id +
','
;
}
}
}
and in the code behind.
// At the conclusion of every postback
hfWindowIds.Value =
""
;
foreach (RadWindow rw
in
rwmPromote.Windows)
{
hfWindowIds.Value += rw.ClientID +
','
;
}
// And then on the ValueChanged event for the HiddenField
protected void hfWindowIds_ValueChanged(object sender, EventArgs e)
{
char[] sep = {
','
};
string[] WindowIds = ((HiddenField)sender).Value.Split(sep, StringSplitOptions.RemoveEmptyEntries);
List<RadWindow> rwList =
new
List<RadWindow>();
foreach (RadWindow rw
in
rwmPromote.Windows)
{
if
(!WindowIds.Contains(rw.ClientID)) rwList.Add(rw);
// No longer open client side
}
foreach (RadWindow rw
in
rwList)
rwmPromote.Windows.Remove(rw);
// Remove each closed window
}
}
This is all working, but I would pre3fer to know the "correct" way to achieve my goal.
Martin
Suggestions welcomed!!