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

Refreshing grid in parent page on closing radwindow

11 Answers 528 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Suvarna
Top achievements
Rank 1
Suvarna asked on 06 Jan 2010, 05:01 AM
Hi, In my parent page i am opening radwindow using following code,

 

RadWindow newwindow = new RadWindow();

 

newwindow.ID =

"RadWindow2";

 

newwindow.NavigateUrl =

"~/ReasonForDisapproval.aspx?elementId=" + elementId + "&stateText=" + stateText + "&contentAvailability=" + contentAvailability;

 

newwindow.VisibleTitlebar =

true;

 

newwindow.Behaviors =

WindowBehaviors.Close;

 

 

newwindow.VisibleOnPageLoad = true;

 

 

 

//add the newly created RadWindow to the RadWindowManager

 

RadWindowManager1.Windows.Add(newwindow);

now in radwindow, after clicking on submit button i want to close the radwindow and refresh the grid from parent page, i am calling javascript function on submit button, 

lblHeading.Text = "<script type='text/javascript'>CloseAndRebind()</" + "script>";

and my javascript function is 

 

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 CloseAndRebind()

 

{

GetRadWindow().BrowserWindow.refreshGrid(

null);

 

GetRadWindow().Close();

}

 

But its not closing radwindow and also not refreshing grid,  its giving javascript error "object doesnt support this property or methods"

Earlier reply will be appreciated.
Thanks in advance
Suvarna

11 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jan 2010, 05:48 AM
Hello Suvarna,

Have you defined the refreshGrid() method on the parent page? If not, probably this should be the reason for the error. Here's an example for the same approach:

The refreshGrid method should be defined on the main(parent) page, which will in turn fire an ajax request:
js(aspx):
function refreshGrid(arg) 
           { 
             if(!arg) 
             { 
             $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");              
             } 
           } 

Rebind the grid after clearing the sort and group expressions in the AjaxRequest server side event:
c#(aspx.cs):
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
            if (e.Argument == "Rebind"
            { 
                RadGrid1.MasterTableView.SortExpressions.Clear(); 
                RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
                RadGrid1.Rebind(); 
            }             
        }  

Hope this helps..
Princy.
0
Suvarna
Top achievements
Rank 1
answered on 06 Jan 2010, 12:14 PM
Hi Princy,

Thanks for the quick reply, I am new to telerik controls, First time i am using radajaxmanager. In the reply you told about adding refreshGrid() function, but who will exactly call this function, I have added RadAjaxManager as follows

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="AccessoryGrid"> 
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="AccessoryGrid" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
   
</telerik:RadAjaxManager>

and added the function as you told. Is there anything needed in this? Please give more details.

Thanks,
Suvarna
0
Shinu
Top achievements
Rank 2
answered on 06 Jan 2010, 03:07 PM
Hello,

Here is the code that I tried for similar scenario.

ParentPage:

ASPX:
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings>  
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="AccessoryGrid" />  
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
            </AjaxSettings>    
</telerik:RadAjaxManager> 

JavaScript:
 
function refreshGrid(arg)  
           {  
             if(!arg)  
             {  
                  $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");   // Invoking ajaxRequest            
             }  
           }  
This client code will invoke an ajaxRequest and you can perform Rebind from code behind.

CS:
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)  
        {  
            if (e.Argument == "Rebind")  
            {  
                RadGrid1.MasterTableView.SortExpressions.Clear();  
                RadGrid1.MasterTableView.GroupByExpressions.Clear();  
                RadGrid1.Rebind();  
            }              
        }   

Page in RadWindow:

JavaScript:
 
function CloseAndRebind(args) 
     { 
            GetRadWindow().Close(); 
            GetRadWindow().BrowserWindow.refreshGrid(args); 
     } 
The code calls the refreshGrid() method on parent page (which in turn invokes ajaxRequest).

You can refer the following demo for more information: Window Editing

Hope this helps,
Shinu.
0
Aimee Rasmussen
Top achievements
Rank 1
answered on 12 Mar 2010, 11:44 PM

Anytime I try to run the line:

$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");    

I get the error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I know that I can change the line to read:

$find("<%# RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");   
 

 to resolve the error (note change from <%= to <%#) but I still always get an error 'null' is null or not an object when it tries to find my control.  I'm assuming it's relating to master pages on my sites.  I can get a handle on the control using $get method but then I get the error Object doesn't support this property or method when trying to call methods as shown in multiple examples on your site..

Do you have any suggestions for the best way to get a handle on the controls when they're inside of master pages??  This drives me nuts!

Thanks!

0
Nikolay Rusev
Telerik team
answered on 15 Mar 2010, 07:16 AM
Hello Aimee,

Simply wrap your JS code around RadScriptBlock. For more details please visit: http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html

Greetings,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jonathan
Top achievements
Rank 1
answered on 12 Apr 2010, 11:36 PM
How would this work when I am opening one radwindow from another and in the first radwindow there is a grid that when I click an item I open a detail item in the second radwindow.  when I close the second radwindow I would like to update the grid in the first radwindow via an ajax call using an ajax manager in the first radwindow.  My scenario is that I have a grid of hotline calls, when I am editing a hotline call in a popup rad window I have a grid of followups to the call as part of the hotline call page.  I'd like to be able to communicate via ajax between the second radwindow editing the followup to the first radwiindow editing the hotline call.

I open a second radwindow from the first with a javascript function using the radwindow manager at the browser level window.

 

 

        function openAddFollowUpWindow() {  
            //open a new window for adding a client FollowUp parsing the URL request for the current client ID  
            var oManager = GetRadWindow().GetWindowManager();  
            var oWnd = oManager.Open("FollowUpPopup.aspx", "RadWindow1"); //  
            //var oWnd = radopen("FollowUpPopup.aspx", "Add FollowUp");  
            oWnd.set_modal(true);  
            oWnd.setSize(800, 500);  
            oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Reload);  
            oWnd.set_visibleStatusbar(false);  
            oWnd.Center();  
        }  
 

In the case of closing a radwindow and updating the grid on the parent browser level page I would place something like this javascript on the parent page.

    function refreshRecentHotlineCallsGrid() {  
        var radMgr = $find("<%=RadAjaxManager1.ClientID %>");  
        radMgr.ajaxRequest("Rebind_RecentHotlineCalls");  
    }  
 

then call it using some code behind in the child window:

        //call the client side CloseAndRebind on reload of page after postback which calls the parent refresh grid  
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);  
 

 coupled with a javascript function in the child window:

        function GetRadWindow()     
        {     
            var oWindow = null;     
            if (window.radWindow) oWindow = window.radWindow;     
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;     
            return oWindow;     
        }     
          
        function CloseAndRebind(args)  
        {  
            GetRadWindow().BrowserWindow.refreshRecentHotlineCallsGrid(args);  
            GetRadWindow().Close();  
        }  
 


so how would I make the call to the other radwindow rather than the parent window?

In the other radwindow I have the javacript code:

        function refreshFollowUpsGrid() {  
            var radMgr = $find("<%=RadAjaxManager1.ClientID %>");  
            radMgr.ajaxRequest("Rebind_FollowUps");  
        } 

Cheers
Jonathan

0
Nikolay Rusev
Telerik team
answered on 15 Apr 2010, 04:50 PM
Hello Jonathan,

If I understand your scenario correctly you are looking for functionality similar to what  is demonstrated on the demo bellow:
http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx

Regards,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jonathan
Top achievements
Rank 1
answered on 16 Apr 2010, 11:15 PM
True yes, however the listed code does not describe the interaction between the dialogs only between the first dialog and the browser window  i.e. default.aspx.  Where is the code for the other two windows?
0
Nikolay Rusev
Telerik team
answered on 21 Apr 2010, 03:52 PM
Hello Jonathan,

Actually the code for the communication between Dialog1 and Dialog2 is listed - you can choose both aspx and cs code the code viewer in the example.

In Dialog2.aspx you can see that when button Ok is pressed returnValue  get called and selected city is transferred to Dialog1.aspx by calling:
....
  
// Get a reference to the first RadWindow's content
var contentWin = dialog1.get_contentFrame().contentWindow
                  
//Call the predefined function in Dialog1
contentWin.populateCityName(selectedCapital); 
....


All the best,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Basel Nimer
Top achievements
Rank 2
answered on 18 May 2010, 05:26 PM
the radGrid is rebound, but the ajaxrequest is not invoked in my case!!!

please help

0
Nikolay Rusev
Telerik team
answered on 20 May 2010, 08:44 AM
Hello Basel,

Please check the following demo:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

All the best,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Ajax
Asked by
Suvarna
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Suvarna
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Aimee Rasmussen
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Jonathan
Top achievements
Rank 1
Basel Nimer
Top achievements
Rank 2
Share this question
or