Refresh RadGrid On Close of RadWindow

2 posts, 0 answers
  1. Ronan BARRANGER
    Ronan BARRANGER avatar
    24 posts
    Member since:
    Mar 2010

    Posted 21 Mar 2012 Link to this post

    Greetings,

    I have a radgrid with an image on each lines which opens a radwindow. When i close My radwindow i need to refresh the grid which is in the parent page.


    This is how i close my radwindow:

                        
        <asp:Button ID="Validation" runat="server" Text="Enregistrer et envoyer l'offre" OnClick="Validation_Click"
    OnClientClick="if(Page_ClientValidate()) CloseDialog()" UseSubmitBehavior="false"
     />
        
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }
     
    function CloseDialog() {
        GetRadWindow().close();
        return true;
     
     
    }


    I tried to do it that way in my parent page:

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" Width="700px" Height="500px" Title="Details du ticket"
                Skin="WebBlue" Behaviors="Close, Move" Modal="true" OnClientClose="closeRadWindow">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    JS:

    <script type="text/javascript"
    function closeRadWindow() 
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();  
    </script>
    .CS

    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        RadGrid1.MasterTableView.SortExpressions.Clear();
        RadGrid1.MasterTableView.GroupByExpressions.Clear();
        RadGrid1.Rebind();
    }


    It doesn't work. Is there anything i'm missing

    (got a JS error with IE ( Property id null or undefined ), & no error but not working at all with firefox)

    thanks in advance
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5243 posts

    Posted 23 Mar 2012 Link to this post

    Hi Ronan,

    This is working correctly with me: http://screencast.com/t/3iXbQ8opu. You can find here my sample page as well so you can compare it with yours and try to locate the difference that is causing this behavior. What I can suggest is that you review if any other script is throwing an error which will prevent AJAX from working. You can also try calling the ajaxRequest() method with a small timeout. i.e.:
    setTimeout(function ()
    {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
    }, 100);

    If this works you can reduce the timeout, even 0ms could suffice.

    Kind regards,
    Marin
    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.
Back to Top