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

ReBinding Grid on ParentPage on Close of RadWindow

1 Answer 62 Views
Window
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 22 May 2012, 01:28 PM
Hi Guys hope someone can help, i know this is covered in another thread but im having an issue with the radwindow and rebinding the grid on my parent page.

I have a RadWindow that i open when i click a button on the ParentPage, the window opens as a modal window i am using thos to have a document upload on the new window.  Once the document is uploaded i want the user to be able to click a close button on the radwindow and this close the window and rebind my grid on my parent page.

When my radWindow opens it is modal as the background is greyed out,once i have uploaded a document when i click my close button which is Button1 in this case , the window closes rebinds the grid as i want it to but then the radwindow opens again but not in a modal state and i am unable to close it.

Javascript on my parent page is 
<script type="text/javascript">
         
        function openWin() {
            var value = '<%=MeetingID %>';
            var oWnd = radopen("DocumentUpload.aspx?MeetingID=" + value, "WindowDocumentUpload");
 
        }
 
        function getRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
 
        function refreshGrid(arg) {
            if (!arg) {
                $find("<%= RadAjaxManagerCreateMeeting.ClientID %>").ajaxRequest("Rebind");
            }
            else {
                $find("<%= RadAjaxManagerCreateMeeting.ClientID %>").ajaxRequest("RebindAndNavigate");
            }
        }
 
        function OnClientFileOpen(oExplorer, args) {
            //get the extension of the opened item
            //            var item = args.get_item();
            //            var fileExt = args.get_item().get_extension();
 
            //            if (fileExt == "xlsx" || fileExt == "docx") {
            //                args.set_cancel(true);
            //                var requestImage = "FileSystemHandler.ashx?path=" + item.get_url();
            //                document.location = requestImage;
            //            }
            //if (fileExt && fileExt.toLowerCase() == "pdf") {
            //cancel the default behavior
            args.set_cancel(true);
            //open new RadWindow
            var oWnd = radopen(args.get_item().get_path(), "RadWindow1");
            //set size to the newly opened RadWindow
            oWnd.center;
            oWnd.setSize(850, 500);
 
 
            //if you want to open the PDF file in a new browser window
            //you can use the following code
            //window.open(args.get_item().get_path());
            //    }
        }
 
 
    </script>


Javascript in my radwindow page is 
<script type="text/javascript">
              function CloseAndRebind(args) {
                  GetRadWindow().BrowserWindow.refreshGrid(args);
                  GetRadWindow().close();
              }
 
              function GetRadWindow() {
                  var oWindow = null;
                  if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                  else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
 
                  return oWindow;
              }
 
              function CancelEdit() {
                  GetRadWindow().close();
              }
      </script>

Then the VB in my Radwindow Page is 

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
  End Sub

Hope you can help 

Thanks 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 24 May 2012, 04:11 PM
Hi Anthony,

This code seem ok and the reason for this behavior may be somewhere in the server handler for the AJAX request - e.g. a call to a JavaScript function that opens a RadWindow without the necessary properties set. It is also possible that it originates in code you have not pasted here, as I currently do not know what your RadWindow declaration is.

Such an unresponsive RadWindow is usually due to calls to methods like center(), moveTo() or setSize() on a closed RadWindow, as they repaint the popup element and show it, but the handlers for the close button are not attached in these functions. I would, therefore, advise that you examine your event handlers and the rest of your code for similar calls. You can locate the problem by stripping out code piece by piece until the problem goes away so you can pinpoint its location.


Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Anthony
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or