This is a migrated thread and some comments may be shown as answers.

Close button not working after reopen window

5 Answers 135 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alex Dybenko
Top achievements
Rank 2
Alex Dybenko asked on 01 Jun 2020, 08:13 AM

Hi,

if I close RadWindow and then reopen it using .setVisible(true) on client side - close button in window title not working anymore. Is it possible to fix this?

here a sample page, press open, close window, press reopen, try to close - nothing happens.

<%@ 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">
<head>
    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
        function TestCloseDates() {
            var manager = GetRadWindowManager();
            var oWnd = manager.getWindowById('wndDates');
            oWnd.setVisible(true);
            //oWnd.restore();
            oWnd.setActive(true);
        }
    </script>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <input type="button" value="Open" onclick="window.radopen('', 'wndDates');"  />
        <input type="button" value="Reopen" onclick="TestCloseDates();"  />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadWindowManager ID="wnd1" runat="server">
            <Windows>
                <telerik:RadWindow Height="365px" Width="375px" ID="wndDates" runat="server" ReloadOnShow="True" >
                    <ContentTemplate>
                        Hi There!
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    </form>
</body>
</html>

Thanks,

Alex

 

5 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 04 Jun 2020, 07:19 AM

Hi Alex,

Calling the RadWindow's show() method instead of setVisible() will allow you not only to make the control's elements visible, but to be able to use its functionality (like buttons, etc):

        function TestCloseDates() {
            var manager = GetRadWindowManager();
            var oWnd = manager.getWindowById('wndDates');
            oWnd.show();
            oWnd.setActive(true); //you can skip this
        }

 

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Alex Dybenko
Top achievements
Rank 2
answered on 05 Jun 2020, 07:09 AM

Hi Vessy,

the problem with .show that window content get reloaded, but using .setVisible(true) - everything, what user selected/entered is kept.

Is it possible to show window again, but keep it content plus close button working?

Alex

0
Vessy
Telerik team
answered on 10 Jun 2020, 07:03 AM

Hi Alex,

The content of RadWindow is not reloaded by default when the window is shown - https://www.screencast.com/t/x0W8xwRL

Do you have any custom implementation forcing that?

Below is the code I used for the recorded test. You can also try setting the ReloadOnShow="False" property of the window and see if this will bring the target result:

<!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>
    <title></title>
    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
        function TestCloseDates() {
            var manager = GetRadWindowManager();
            var oWnd = manager.getWindowById('wndDates');
            oWnd.show();
            oWnd.setActive(true); //you can skip this
        }
    </script>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <input type="button" value="Open" onclick="window.radopen('', 'wndDates');" />
        <input type="button" value="Open 2" onclick="window.radopen('', 'RadWindow1');" />

        <input type="button" value="Reopen" onclick="TestCloseDates();" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadWindowManager ID="wnd1" runat="server" ReloadOnShow="false">
            <Windows>
                <telerik:RadWindow Height="365px" Width="375px" ID="wndDates" runat="server" ReloadOnShow="True">
                    <ContentTemplate>
                        Hi There!
                        <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox>
                    </ContentTemplate>
                </telerik:RadWindow>
                <telerik:RadWindow Height="365px" Width="375px" ID="RadWindow1" runat="server" ReloadOnShow="True">
                    <ContentTemplate>
                        Hi There!
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    </form>
</body>
</html>

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Alex Dybenko
Top achievements
Rank 2
answered on 11 Jun 2020, 07:09 AM

Hi Vessy,

I need  ReloadOnShow, when user opens window, but also I need to give user option to show back closed window, which is actually hidden, with same content when it closed. Anyway, found this code, which solved my problem, can be useful for others, or myself after some time :)

Alex

Telerik.Web.UI.RadWindow.prototype.old_restore = Telerik.Web.UI.RadWindow.prototype.restore;
           Telerik.Web.UI.RadWindow.prototype.restore = function () {
               this.old_restore();
               if ($telerik.getVisible(this._popupElement))
                   this._popupVisible = true;
               else
                   this._popupVisible = false;
           };
 
0
Vessy
Telerik team
answered on 12 Jun 2020, 08:43 PM

Hi,

Thanks a lot for the clarification and the shared solution, Alex :) I am sure it will be very helpful to the other users facing the same issue.

Kind regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Window
Asked by
Alex Dybenko
Top achievements
Rank 2
Answers by
Vessy
Telerik team
Alex Dybenko
Top achievements
Rank 2
Share this question
or