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

window refresh

7 Answers 148 Views
Window
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 20 Jul 2011, 06:06 PM
I have a radwindow that contains a grid.  Selecting an item in the grid activates a second radwindow that allows the selected grid item to be edited.  Clicking 'update' in the 2nd radwindow should close the window and rebind the grid in the first window.  I just cant get this to work, when ever I close the second window the refresh function never gets fired, heres my code

this activates the 2nd window from the grid in the first radwindow

function ShowEditForm(id, rowIndex) {
             
            var grid = $find("<%= RadGrid1.ClientID %>");
            var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
            grid.get_masterTableView().selectItem(rowControl, true);
            var oBrowserWnd = GetRadWindow().BrowserWindow;
            oBrowserWnd.radopen("BandMemberEditForm.aspx?ID=" + id, "BandMemberDialog");
            return false;
        }




this code should refresh the grid when the 2nd radwindow closes

function refreshGrid(arg) {
            //debugger;
            alert("refresh grid");
            if (!arg) {
                $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind");
 
            }
            else {
                $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate");
 
 
            }
        }



in the 2nd radwindow, I have this code to close the window and rebind the grid in the first window

function CloseAndRebind(args) {
        alert("close and rebind");
        GetRadWindow().Close();
        //debugger;
        //var oWindow = GetRadWindow();
        GetRadWindow().BrowserWindow.refreshGrid(args);
    }


I know this function is called because of the alert, but the refreshGrid function never gets called

can anyone see what im doing wrong here ?

7 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 21 Jul 2011, 12:33 PM
Hi Mark,

The refreshGrid() function resides in the first RadWindow, which is a separate iframe as I understand from your code. This means that you need another step in the main page before you can call this function:

the function from the second RadWindow that will access the main page:
function CloseAndRebind(args) {
        alert("close and rebind");
        GetRadWindow().BrowserWindow.CallFn(args); 
        GetRadWindow().Close();
    }

A function in the main page that will access the first RadWindow that contains the actual grid and the refreshGrid() function:
function CallFn()
{
  var oWnd = GetRadWindowManager().getWindowByName("RadWindow1"); //put your actual RadWindow name hare
  oWnd.get_contentFrame().contentWindow.refreshGrid(args); 
}

and then the refrsehGrid() function should be executed.

Please try this whole cycle and let me know how it goes.

  
Kind regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
mww
Top achievements
Rank 1
answered on 21 Jul 2011, 05:09 PM
I take it by name you mean ID ?
0
mww
Top achievements
Rank 1
answered on 21 Jul 2011, 05:15 PM
that didnt work, if i use the code you supplied, the second window doesnt close, if I change it to this

alert("close and rebind");
        GetRadWindow().Close(); ---  moved the close to here
        GetRadWindow().BrowserWindow.CallFn(args);

the refreshgrid doesnt fire

Ive placed this function in my master page

function CallFn() {
                var oWnd = GetRadWindowManager().getWindowByName("ArtistDialog"); //put your actual RadWindow name hare
                oWnd.get_contentFrame().contentWindow.refreshGrid(args);
            }
0
mww
Top achievements
Rank 1
answered on 21 Jul 2011, 05:22 PM
The window is activated from  a menu contained in the master page, so the browserwindow varies depending on the page im currently on, I think thats where the problem is.  How can I get this functionality to work with a master page ?
0
Marin Bratanov
Telerik team
answered on 22 Jul 2011, 03:55 PM
Hello Mark,

Whether the code is in a master page or a regular page does not change the window object, the difference is mostly that the master page creates an INaming container and changes the IDs of the elements. Please examine the following article for more information on the frame tree and hierarchy: http://old.jr.pl/www.quirksmode.org/js/frameintro.html.

Nevertheless I created a simple project that illustrates the approach and attached it to this thread. Please examine it and try to implement the logic in your actual project. It should work regardless of the master page that hosts the RadWindows.


Regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
mww
Top achievements
Rank 1
answered on 23 Jul 2011, 10:09 AM
thanks for the example, it is partially working now.  In the first window this function is being called when the second window closes

function refreshGrid(arg) {
            //debugger;
            alert("refresh grid : " + arg);
            if (!arg) {
                //$find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind");
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequestWithTarget("<%= RadGrid1.UniqueID %>", "Rebind");
 
            }
            else {
                //$find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate");
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequestWithTarget("<%= RadGrid1.UniqueID %>", "RebindAndNavigate");
 
            }
        }


When the first window is closed, I want to refresh the grid in the first window, but the ajaxrequest doesnt seem to get fired.

I have an ajax manager on my master page, and this ajax proxy on the content page

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManagerProxy1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/>
                        </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>


in my code behind (of the first window)  I have this

protected void RadAjaxManagerProxy1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
 
            switch (e.Argument)
            {
                case "Rebind":
                    this.RadGrid1.Rebind();
                    break;
            }
 
        }

this code never gets executed.  I need to rebind the grid in the first content window when the second edit window closes.  Am I going about this in the right way ?
0
Marin Bratanov
Telerik team
answered on 26 Jul 2011, 02:13 PM
Hi Mark,

The way to call the functions is correct and I assumed that you had the correct AJAX settings in place. This, however, does not have a server-side handler for the AjaxRequest event and the ajaxRequestWithTarget() function requires that the controls (the grid and the ajax manager) are added to the RadAjaxManager in the master page. This can only happen programmatically, as they come from different pages and is more difficult. What I would advise is that you use the ajaxRequest() function, as you only need to rebind the grid. The difference between these two functions is that the former is used to simulate postbacks from different elements, which is a rather peculiar scenario. For more information on the matter please examine the following articles:
http://www.telerik.com/help/aspnet-ajax/ajax-client-side-api.html
http://www.telerik.com/help/aspnet-ajax/ajax-ajaxmanagerproxy.html
http://www.telerik.com/help/aspnet-ajax/ajax-masterpage.html

  Nevertheless I modified my test page to execute the Grid rebinding and AjaxRequests (albeit giving no datasource to the grid, but that is not relevant to the case). You can find it attached as a reference. Please examine it and try to incorporate the logic in your actual application. You can find a video with the expected behavior from my sample here: http://screencast.com/t/o6CeKJcG2jG.

I hope my reply was helpful.


Kind regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Window
Asked by
mww
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
mww
Top achievements
Rank 1
Share this question
or