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

RadWindow closes, now update/refresh radGrid on parent page

35 Answers 2352 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 10 Mar 2008, 01:23 PM
Hi all,

You guys have helped me out tremendously in getting my radwindow working.  I now have another question.  When I am finished with my pop-up radwindow I click a button that closes the pop-up and returns to the parent page.  How can I make the parent page postback and refresh?

Thanks,
Bob

35 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 2
answered on 10 Mar 2008, 01:27 PM
Hi Bob,
 I was after the same question.  Here is what I got from telerik.

You can hook to the OnClientClose event of the RadWIndow and use document.location.reload() or document.location.href = document.location.href to reload / refresh the page.

e.g.
<script type="text/javascript">
function OnClientClose(sender,args)
{
//your code here
}
</script>
<telerik:radwindow id="RadWindow1" runat="server" OnClientClose="OnClientClose" />

 

Best wishes,
Georgi Tunev
the Telerik team


--Brett

0
Bob
Top achievements
Rank 1
answered on 10 Mar 2008, 01:41 PM
Hey Brett.  Thanks for the reply.  Here is my javascript function that runs when the user clicks the close button:

function

closeWin()

{

var oWnd = GetRadWindow();

oWnd.close();

document.location.reload();

}

I added the document.location.reload(); line like you suggested.  But the parent page still does not refresh after clicking the button.  Did I put this line in the proper spot?

Thanks,
Bob

0
Georgi Tunev
Telerik team
answered on 10 Mar 2008, 01:53 PM
Hi Bob,

The function that Brett posted should be placed in the parent page - where your RadWindow / RadWindowManager is. This function should also be hooked to the RadWindow with the OnClientClose property as shown in the code.

If you want to put the refreshing code in the content page, you need to replace document with top. This way you will refer to the topmost page which will be the one from which you open the RadWindow.
e.g.
top.location.reload() (equal to pressing F5 on the parent page)
OR
top.location.href = top.location.href;




Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Bob
Top achievements
Rank 1
answered on 10 Mar 2008, 02:18 PM
Georgi,

Now I am totally confused.  I have the following javascript function in the HTML of my pop-up page.

function

closeWin()

{

var oWnd = GetRadWindow();

oWnd.close();

}

Are you telling me that this code should instead be in the HTML of my parent page?


Thanks,
Bob

0
Georgi Tunev
Telerik team
answered on 10 Mar 2008, 04:56 PM
Hello Bob,

What I mean was that if you want to refresh the parent page from your content one, you should modify the closeWin() function that you have on the content page:

function closeWin() 
    var oWnd = GetRadWindow(); 
    oWnd.close(); 
    top.location.href = top.location.href; 
}  


If you need the refreshing code to be called from the parent page, you can use the code that Brett posted. There you hook to the OnClientClose event of the RadWindow which is fired when the RadWindow is closed and call the reloading code there.

I hope this helps.

Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brett
Top achievements
Rank 2
answered on 10 Mar 2008, 08:01 PM
I am still trying to work out my issues too...So here is where I am at.

In my parent:
I have 3 buttons, they all launch windows.  My button code looks like this.
<asp:ImageButton   
        runat="server" ID="btnContact" ImageUrl="~/lib/img/vcard_add.png" ToolTip="Add Contact" CausesValidation="False"   
        OnClientClick="openWin(winContact); return false;"/> 

Then I have my Window Manager and Windows...looks like this:

 <telerik:RadWindowManager ID="rwm" runat="server"   
        Animation="None" Skin="Default" Behavior="Default" Behaviors="Default"   
        InitialBehavior="None" InitialBehaviors="None" Left="" style="display: none;"   
        Top="" VisibleStatusbar="False" Width="500px" Height="500px" Overlay="True">  
        <Windows> 
            <telerik:RadWindow ID="winContact" runat="server"    
                Behavior="Default" Behaviors="Default" InitialBehavior="None"   
                InitialBehaviors="None" Left="" NavigateUrl="../contacts/add.aspx"   
                style="display:none;" Top="" IconUrl="../../lib/img/vcard_add.png"   
                Title="Add Contact">  
            </telerik:RadWindow> 
            <telerik:RadWindow id="winListing" runat="server" Behavior="Default"   
                Behaviors="Default" InitialBehavior="None" InitialBehaviors="None" Left=""   
                NavigateUrl="../listings/add.aspx" style="display:none;" Top=""   
                IconUrl="../../lib/img/world_add.png" Title="Add Listing">  
            </telerik:RadWindow> 
            <telerik:RadWindow id="winAdvertising" runat="server" Behavior="Default"   
                Behaviors="Default" InitialBehavior="None" InitialBehaviors="None" Left=""   
                NavigateUrl="../advertising/add.aspx" style="display:none;" Top=""   
                IconUrl="../../lib/img/transmit_add.png" Title="Add Advertising">  
            </telerik:RadWindow> 
        </Windows> 
    </telerik:RadWindowManager> 

But when I click my buttons I get a run-time error that say "winContact" is undefined or whichever button I click.  My javascript looks like this:

<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 closeWin()  
   {  
    var oWnd = GetRadWindow();   
    oWnd.close();  
   }  
function openWin()  
   {  
    var oWnd = GetRadWindow();  
    oWnd.show();  
   }           
</script> 


What Am I doing wrong?
0
Georgi Tunev
Telerik team
answered on 11 Mar 2008, 08:30 AM
Hello Brett,

In the OnClientClick property you have set:

OnClientClick="openWin(winContact); return false;"

Since you haven't defined winContact before, the framework will throw an error. I assume that you wish to open the RadWindow with ID "winContact", am I right? If this is so, you need to set the argument as a string

OnClientClick="openWin('winContact'); return false;" //note the single quotes


And then to set your openWin function like this:

function openWin(winName) 

    var oWnd = GetRadWindowManager().GetWindowByName(winName);
    oWnd.show(); 
}



I hope this helps. Note that the GetRadWindow function is not used - this function is intended to be used in content pages only, when you want to refer the RadWindow in which this page was shown.
More information on the subject and code snippets can be found in the documentation, section Controls / RadWindow / Programming.



Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brett
Top achievements
Rank 2
answered on 11 Mar 2008, 04:51 PM
That worked perfectly!

Thanks as always.
0
Paul Cook
Top achievements
Rank 1
answered on 24 Mar 2008, 07:49 PM
This refreshes the entire page, but is there a way to refresh just the RadGrid. I don't want to refresh the whole page, just the contents of the grid.
0
Georgi Tunev
Telerik team
answered on 25 Mar 2008, 08:16 AM
Hello Paul,

In this case you should call a Javascript function on the parent page that will refresh the grid only. For a sample implementation of this logic, please check the following demo: Window Editing - note the CloseAndRebind() function in the content page and the refreshGrid() function on the parent.



All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paul Cook
Top achievements
Rank 1
answered on 25 Mar 2008, 10:39 AM
Hi Georgi,

This is just what I need, thanks.

I've tried integrating with my project but am having difficulty getting the following line to work:

GetRadWindow().BrowserWindow.refreshGrid(args);

Is the sourcecode available for this sample? I can't see it in the download.

Thanks, Paul.
0
Georgi Tunev
Telerik team
answered on 25 Mar 2008, 11:16 AM
Hello Paul,

If you have installed the latest official release of the RadControls Prometheus suite, the example is available in your Live Demos\Controls\Examples\Integration\GridAndWindow folder.

For convenience I attached the sample files to this thread.



Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paul Cook
Top achievements
Rank 1
answered on 25 Mar 2008, 11:20 AM
Hi Georgi,

I eventually found it in my code suite.

I've located the problem and solved the problem (a typo) - solution works nicely.

Many thanks, Paul.
0
lawanya
Top achievements
Rank 1
answered on 16 Apr 2008, 09:17 PM
Hello guys,

I followed the example provided in GridAndWindow.Zip by georgi. Thanks for that. I have this problem, when I close the rad window and call the refreshGrid(args) function in parentGrid, I receive a javascript error saying the "object doesn't support this property or method". Any thoughts?

Regards, 
Lawanya

 
0
Georgi Tunev
Telerik team
answered on 17 Apr 2008, 08:53 AM
Hello lawanya,

Make sure that you are using the new ASP.NET AJAX naming conventions as shown in theChanges and Backwards Compatibility section of the documentation.

If you still experience problems, it will be best to open a support ticket and send us your project - we will check it right away.


All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shaun Peet
Top achievements
Rank 2
answered on 17 Apr 2008, 01:18 PM
It's too bad I didn't notice this thread earlier.  I actually posted a code library project several months ago that demonstrates how to accomplish exactly what you're after:

http://www.telerik.com/community/code-library/submission/b311D-bbcdde.aspx

It used the Prometheus versions of the controls, so there may be a set_Height instead of set_height here or there, but I continue to use this methodology all over the place and it works very well.

Shaun.
0
Nicklas
Top achievements
Rank 1
answered on 18 Apr 2008, 12:32 PM
I got the top.location.reload() to work, it successfully reloads my page; however, I was wondering if there was a way I could extend this to instead of reloading my entire page, simply reloading an radajaxmanager that I have on the parent page. Is there a simple way of doing that?
0
lawanya
Top achievements
Rank 1
answered on 18 Apr 2008, 01:01 PM
try the following in refreshGrid function and add a onajaxrequest event handler for your RadAjaxManager

function

refreshGrid()

var radMgr = $find("<%=PrometheusRadAjaxManager.ClientID %>"); radMgr.ajaxRequest("Rebind");



<

telerik:RadAjaxManager ID="PrometheusRadAjaxManager" runat="server" onajaxrequest="PrometheusRadAjaxManager_AjaxRequest">
<
AjaxSettings><telerik:AjaxSetting AjaxControlID="PrometheusRadAjaxManager">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="PrometheusRadGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</
telerik:RadAjaxManager>

And in code behind use this code, 

protected void PrometheusRadAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if (e.Argument == "Rebind")
{
PrometheusRadGrid.MasterTableView.SortExpressions.Clear();
PrometheusRadGrid.MasterTableView.GroupByExpressions.Clear();
PrometheusRadGrid.Rebind();
}
}

Hope this helps

Lawanya

0
Nicklas
Top achievements
Rank 1
answered on 18 Apr 2008, 01:08 PM
Ok, I guess I should have been more specific about my problem. What I have on my parent page is this, a raddock, with a radajaxpanel in a docking zone with a radcalendar in that ajaxpanel. When I close the radwindow, I want the radcalendar to refresh (esentially, have the ajaxpanel postback). Is this possible using the code you provided?
0
Lini
Telerik team
answered on 22 Apr 2008, 07:41 AM
Hi,

The RadAjaxPanel also has an .ajaxRequest() method you can use to initiate an ajax request.
the code is essentially the same on the client:

<script type="text/javascript">
function refreshCalendar()

var ajaxPanel = $find("<%=yourAjaxPanel.ClientID %>"); ajaxPanel.ajaxRequest();

</script>

All the best,
Lini
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nicklas
Top achievements
Rank 1
answered on 22 Apr 2008, 12:18 PM
Ok, tried that, but it couldn't find the ajaxpanel inside of the raddock. I then moved the panel outside of the dock, and it found it, but I got an "Object Expected" error when the script ran. I put the line in the OnClientClose of the window, here is the entire script:

    function OnClientClose(radWindow)      
        {      
            if(document.documentElement && document.documentElement.scrollTop)      
            {      
                document.documentElement.scroll = "";      
                document.documentElement.style.overflow = "";      
            } else if(document.body)      
            {      
                document.body.scroll = "";      
                document.body.style.overflow = "";      
            }  
            var ajaxPanel = $find("<%=rapSchedule.ClientID %>"); ajaxPanel.ajaxRequest();     
        }         
 

0
Nicklas
Top achievements
Rank 1
answered on 22 Apr 2008, 01:23 PM
Ok, I finally figured it out! Thanks for all of you help, that line worked perfectly!
0
Nicklas
Top achievements
Rank 1
answered on 22 Apr 2008, 03:16 PM
ok, it looks like my elation was a little too quick. The code still doesn't work, I guess I just didn't notice it. So here is what I have tried...if I put the code on the parent page, when I click my button to close the RadWindow, nothing happens (I see an error thing pop up in IE, but it goes away before I can check the error). If I put the code in the page that loads in the window, it says that it cannot find the ajaxpanel. ARRRGGGHHH! I so want this to work! I am sorry that I am being so difficult, but I don't know much about JavaScript, so I am really beating my head trying to figure it out!!!

Incidentally, here is the new code. I have it assigned to the OnClientClick of a button in my radwindow page:
        function CancelEdit() 
        { 
            GetRadWindow().Close();  
            var ajaxPanel = $find("<%=rapSchedule.ClientID %>"); ajaxPanel.ajaxRequest();    
        } 

0
Accepted
Nicklas
Top achievements
Rank 1
answered on 22 Apr 2008, 03:40 PM
Ok, got it working now it would appear. I used window["<%=rapSchedule.ClientID %>"].AjaxRequest(); in the parent page, and everything works fine. Thanks!
0
Adam
Top achievements
Rank 1
answered on 10 Nov 2010, 02:17 AM
Thanks,  you guys know your stuff.
0
Gary
Top achievements
Rank 1
answered on 20 Jul 2011, 01:23 PM

I had a similar problem to the one that was presented. I had a RadGrid control in an ASP.NET table inside a Rad Multi Page control. Nothing I did seem to update the RadGrid short of refreshing the entire page until I remembered a piece of information in your literature on the RadAjaxManager. Your literature stated that the RadAjaxManager inherited from the Ajax Manager from Microsoft. So I wrapped the grid in an Update Panel and set its update mode property to conditional. Then during the Ajax Request I found the control and forced it to update the panel as the last act. It worked like a charm. My philosophy is why re-invent the wheel when there’s a control for that?

0
Djb
Top achievements
Rank 1
answered on 25 Jan 2012, 08:53 PM
I have the similar situation . I tried using OnlcientClose event on my radwindow. But it then gives me javascript error when i try to get a radwindow 
"Microsoft JScript runtime error: 'undefined' is null or not an object"

This happens only when i use OnclientClose button. Here is my code,

<telerik:RadWindowManager ID="Singleton" Modal="true" runat="server" Skin="Office2007">
        <Windows>
            <telerik:RadWindow Height="400px" Width="750px" runat="server" ID="radwApprover" OnClientClose="javascript:test();return false;"
                Modal="true">                
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

and here is my javascript function

function test(sender,e) {
    alert('Radwindow is being closed.');
};

Can you please help ?
0
Svetlina Anati
Telerik team
answered on 27 Jan 2012, 09:16 AM
Hi guys,

Gary, indeed RadAjaxManager can be easily replaced with standard asp update panel in some simple scenarios. However, it has much more intuitive and easy settings when configuring more complex scenarios. For example with the manager you do not need to specify triggers, to handle the PageRequestManager request events, to use Application.load handler when executing script from the server after AJAX, etc. For many of our customers this is a big convenience and thus we have developed the control. However, if you are dealing with a more simple scenario and you prefer to use standard update panel, you can do that since all of our controls are perfectly integrated with MS AJAX and they do not require using RadAjax.

Djb, when you attach client handlers for RadControls, you should simply set the name of the function which is the handler as shown below:

OnClientClose="test"

while you have tried to attach the handler as for a standard asp button control.

Please, revise your code and let us know e=whether this fixed the problem.

Kind regards,
Svetlina Anati
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
0
TippCityTom
Top achievements
Rank 1
answered on 19 Feb 2013, 07:26 PM
how would you do this if your RadAjaxManager is on master page, grid is in content page?
0
Spiros
Top achievements
Rank 1
answered on 12 Jun 2014, 07:25 AM
Hi Guys.
I am updating the grid before the RadWindow close.

            function Close() {
                
                debugger
                var id = document.getElementById("<%= hdnCoverId.ClientID %>").value;
                var selection = document.getElementById("<%= cmbApallagi.ClientID %>").value;

                //alert(id);
                var grid = $find("<%=grdCovers.ClientID %>");
                var MasterTable = grid.get_masterTableView();
                var items = MasterTable.get_dataItems();

                // get the # of rows
                var length = MasterTable.get_dataItems().length;

                for (var i = 0; i < length; i++) {
                    // get the record
                    var record = MasterTable.get_dataItems()[i];
                    var keyValue = record.getDataKeyValue("Id")
                    var lbNom = record.findElement("lblNominal");      //access the Label

                    if (keyValue == id && selection == 2) {
                        //console.log(keyValue);
                        lbNom.innerText = "1";                             // assigning value to label control
                    }
                    else
                    {
                        lbNom.innerText = "0";                             // assigning value to label control
                    }

                }

                // and rebind it to the changed data
                MasterTable.updateEditedItems();

                var oWindowCust = $find('<%= RadWindow2.ClientID %>');
                oWindowCust.Close();

            }

Everything works fine but the rest of the controls does not work. I mean not a single event is raised.
Any idea ?
Thanks in advance.
Spiros
0
Marin Bratanov
Telerik team
answered on 13 Jun 2014, 03:26 PM

Hello Spiros,

From the way you reference the controls, it seems they are all on the same page, so the RadWindow's ContentTemplate is used. If this is not the case you would need to access the parent page's grid properly.

The most likely reason for lose of interactivity on the page is a JavaScript error, so I advise that you examine the browser console and debug the scripts to see if/what error is raised in order to fix it.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Asutosh
Top achievements
Rank 1
answered on 10 Jul 2014, 06:18 AM
hi 
i have rad grid in my rad window
it has maximize functionality in rad window 
so when i maximize that my grid popup of filter is not open 
also i have dropdown is in rad window so when i maximize radwindo my dropdown is also not open 
i have attached error image 
i have marked error in images

0
Marin Bratanov
Telerik team
answered on 10 Jul 2014, 10:22 AM

Hello Asutosh,

Based on this information, it seems you are using your RadWindow(s) with their ContentTemplate. In this case all their content is on the same page and z-index rules apply to it: http://www.telerik.com/help/aspnet-ajax/controlling-absolute-positioning-with-zindex.html. A maximized RadWindow gets a very large z-index value, so other absolutely positioned elements like dropdowns would remain behind it.

To avoid this, simply set its ShowOnTopWhenMaximized property to false (it defaults to true).


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Melvin
Top achievements
Rank 1
answered on 14 Apr 2015, 08:43 PM

I need to update the radWindow control from a button that is located internally in the radwindow.

The scenario I have is as follows:
Since a main form I call radwindow and it displays me another form, which contains a textbox and a radgrid. When I digit something in the textbox and press down on the button to add, I need to reload the radwindow like the effect of having the radwindow.

As I do this?

sorry for my english, is not very good xD!! 

Thank you for your help.

0
Marin Bratanov
Telerik team
answered on 16 Apr 2015, 10:58 AM

Hi Melvin,

I suggest keeping your query in the separate thread you have opened: http://www.telerik.com/forums/how-to-refresh-radwindow.

I would advise that you keep threads concise in the future by posting in relevant threads or opening new ones, instead of branching the main question with another one.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Window
Asked by
Bob
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Georgi Tunev
Telerik team
Paul Cook
Top achievements
Rank 1
lawanya
Top achievements
Rank 1
Shaun Peet
Top achievements
Rank 2
Nicklas
Top achievements
Rank 1
Lini
Telerik team
Adam
Top achievements
Rank 1
Gary
Top achievements
Rank 1
Djb
Top achievements
Rank 1
Svetlina Anati
Telerik team
TippCityTom
Top achievements
Rank 1
Spiros
Top achievements
Rank 1
Marin Bratanov
Telerik team
Asutosh
Top achievements
Rank 1
Melvin
Top achievements
Rank 1
Share this question
or