RadWindow closes, now update/refresh radGrid on parent page

36 posts, 1 answers
  1. Bob
    Bob avatar
    87 posts
    Member since:
    Jan 2008

    Posted 10 Mar 2008 Link to this post

    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
  2. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 10 Mar 2008 Link to this post

    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

  3. Bob
    Bob avatar
    87 posts
    Member since:
    Jan 2008

    Posted 10 Mar 2008 Link to this post

    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

  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 10 Mar 2008 Link to this post

    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
  5. Bob
    Bob avatar
    87 posts
    Member since:
    Jan 2008

    Posted 10 Mar 2008 Link to this post

    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

  6. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 10 Mar 2008 Link to this post

    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
  7. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 10 Mar 2008 Link to this post

    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?
  8. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 11 Mar 2008 Link to this post

    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
  9. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 11 Mar 2008 Link to this post

    That worked perfectly!

    Thanks as always.
  10. Paul Cook
    Paul Cook avatar
    17 posts
    Member since:
    Jan 2005

    Posted 24 Mar 2008 Link to this post

    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.
  11. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 25 Mar 2008 Link to this post

    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
  12. Paul Cook
    Paul Cook avatar
    17 posts
    Member since:
    Jan 2005

    Posted 25 Mar 2008 Link to this post

    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.
  13. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 25 Mar 2008 Link to this post

    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
  14. Paul Cook
    Paul Cook avatar
    17 posts
    Member since:
    Jan 2005

    Posted 25 Mar 2008 Link to this post

    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.
  15. lawanya
    lawanya avatar
    3 posts
    Member since:
    Sep 2006

    Posted 16 Apr 2008 Link to this post

    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

     
  16. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 17 Apr 2008 Link to this post

    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
  17. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 17 Apr 2008 Link to this post

    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.
  18. Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 18 Apr 2008 Link to this post

    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?
  19. lawanya
    lawanya avatar
    3 posts
    Member since:
    Sep 2006

    Posted 18 Apr 2008 Link to this post

    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

  20. Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 18 Apr 2008 Link to this post

    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?
  21. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 22 Apr 2008 Link to this post

    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
  22. Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 22 Apr 2008 Link to this post

    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();     
            }         
     

  23. Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 22 Apr 2008 Link to this post

    Ok, I finally figured it out! Thanks for all of you help, that line worked perfectly!
  24. Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 22 Apr 2008 Link to this post

    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:
    1         function CancelEdit() 
    2         { 
    3             GetRadWindow().Close();  
    4             var ajaxPanel = $find("<%=rapSchedule.ClientID %>"); ajaxPanel.ajaxRequest();    
    5         } 

  25. Answer
    Nick
    Nick avatar
    25 posts
    Member since:
    Oct 2007

    Posted 22 Apr 2008 Link to this post

    Ok, got it working now it would appear. I used window["<%=rapSchedule.ClientID %>"].AjaxRequest(); in the parent page, and everything works fine. Thanks!
  26. Adam
    Adam avatar
    1 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2010 Link to this post

    Thanks,  you guys know your stuff.
  27. Gary
    Gary avatar
    1 posts
    Member since:
    Jul 2011

    Posted 20 Jul 2011 Link to this post

    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?

  28. Djb
    Djb avatar
    3 posts
    Member since:
    Jan 2012

    Posted 25 Jan 2012 Link to this post

    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 ?
  29. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 27 Jan 2012 Link to this post

    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
  30. TippCityTom
    TippCityTom avatar
    14 posts
    Member since:
    Sep 2008

    Posted 19 Feb 2013 Link to this post

    how would you do this if your RadAjaxManager is on master page, grid is in content page?
Back to Top