Grid not rebinding on Closing Rad Window

4 posts, 0 answers
  1. SHERFUDEEN
    SHERFUDEEN  avatar
    21 posts
    Member since:
    Apr 2011

    Posted 20 Apr 2011 Link to this post

    Hi , 
    I  have a parent page from which i need to open a rad window where i save/update data. On saving/closing the rad window i need the rad grid in parent to refresh . Grid does not refresh until i do a post back on the page .
    Following is the code i am using , 

    In Master Page :
      <telerik:RadAjaxManager ID="mgr" runat="server" EnableAJAX="true" OnAjaxRequest="mgr_AjaxRequest"> 
                </telerik:RadAjaxManager>
                <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" Skin="Vista"
                    BackgroundPosition="Center" EnableEmbeddedSkins="true" />
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
    In Parent Page (.aspx)
     <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 refreshGrid() {                
                        $find("<%= RadAjaxManager.GetCurrent(this).ClientID %>").ajaxRequest("Rebind");  
                                          
                }      
    </script>
    In Parent Page (.cs)


     protected void Page_Load(object sender, EventArgs e)
        {
            #region AJAX Settings        
            RadAjaxManager mgr = RadAjaxManager.GetCurrent(Page);
            
            mgr.AjaxSettings.Clear();       
            mgr.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(mgr_AjaxRequest);
            mgr.AjaxSettings.AddAjaxSetting(btnSearch, pnlContent);
            mgr.AjaxSettings.AddAjaxSetting(btnSearch, rgcarrrier, (RadAjaxLoadingPanel)(this.Page.Master as MasterPage).FindControl("RadAjaxLoadingPanel2"));
            mgr.AjaxSettings.AddAjaxSetting(rgcarrrier, pnlContent);
            //mgr.AjaxSettings.AddAjaxSetting(RadWindowManager1, rgcarrrier);
            mgr.AjaxSettings.AddAjaxSetting(btnDelete, pnlContent);
            mgr.AjaxSettings.AddAjaxSetting(btnDelete, rgcarrrier, (RadAjaxLoadingPanel)(this.Page.Master as MasterPage).FindControl("RadAjaxLoadingPanel2"));
            mgr.AjaxSettings.AddAjaxSetting(rgcarrrier, rgcarrrier, (RadAjaxLoadingPanel)(this.Page.Master as MasterPage).FindControl("RadAjaxLoadingPanel2"));        
            #endregion


    }




      protected void mgr_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e.Argument == "Rebind")
            {         
                    
                    rgcarrrier.MasterTableView.SortExpressions.Clear();
                    rgcarrrier.MasterTableView.GroupByExpressions.Clear();
                    rgcarrrier.Rebind();                           
               
                
            }
            
        }


    In Rad Window (.aspx)
    <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 cancelAndClose() {
                var oWindow = GetRadWindow();
                oWindow.argument = null;
                            oWindow.close();
                            oWindow.BrowserWindow.refreshGrid();  
                return false;
            }    
              
        </script>

    In Rad Window (.cs)
     protected void Page_Load(object sender, EventArgs e)
        {
            #region Ajax Settings
            RadAjaxManager mgr = RadAjaxManager.GetCurrent(Page);
            mgr.AjaxSettings.Clear();
            #endregion
    }
     protected void btnClose_Click(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "cancelAndClose();", true);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
         (Page.IsValid)
            {
                //when save
                {
                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "cancelAndClose();", true);
    }
    //when Update
    {
     ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "cancelAndClose();", true);
    }
    }


    where did i go wrong ?
    The grid does not refresh ..
  2. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 25 Apr 2011 Link to this post

    Hello,

    I have examined  your code and the mistake I noticed is that you clear the AJAX settings on each Page_Load. Please remove the code doing this and let me know whether this helps.

    Regards,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SHERFUDEEN
    SHERFUDEEN  avatar
    21 posts
    Member since:
    Apr 2011

    Posted 25 Apr 2011 Link to this post

    Hi,

    This issue already solved. I forgot to mark it as solved .

    Thanks
  5. mahesh
    mahesh avatar
    14 posts
    Member since:
    Jun 2011

    Posted 27 Jul 2011 Link to this post

    Grid not rebinding on Closing Rad Window

    I have problem with radgrid refreshing, when i close the radwindow

    my Gridpage aspx code looks like this
     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" EnableAJAX="true">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
                GridLines="None" ShowGroupPanel="True" Skin="Black" AutoGenerateColumns="False" Width="100%" AllowAutomaticInserts="false" AllowAutomaticUpdates="false">
                <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                    <ClientEvents OnGridCreated="OnGridCreated" />
                </ClientSettings>

    .......................
    ..................
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
                Skin="Black">
                <Windows>
                    <telerik:RadWindow ID="UserListDialog" runat="server" Height="620px" Width="620px"
                        Left="150px" Top="50px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"
                        OnClientClose="closeRadWindow" />
                </Windows>
            </telerik:RadWindowManager>
    protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
            {
                if (e.Argument == "Rebind")
                {
                    RadGrid1.MasterTableView.SortExpressions.Clear();
                    RadGrid1.MasterTableView.GroupByExpressions.Clear();
                    Presenter List = new Presenter(this);
                    IList<FileAdmin> GridDta = List.PopulateGrid();
                    RadGrid1.DataSource = GridDta;
                    RadGrid1.Rebind();
                }
    My javascript looks like this
    function closeRadWindow()
                     {
                         $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                      
                    }
           function refreshGrid()
                     {
                       $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                     
                     }
    RadWindow aspx code Looks like this
    javascript
     function CloseAndRebind() {
                            GetRadWindow().BrowserWindow.refreshGrid();
                            //GetRadWindow().close();
                        }
    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;
                        }
    Radwindow aspx.cs file looks like this
    protected void buttonclick(object sender, EventArgs e)
    {
    if (result == true)
     {
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey1", "CloseAndRebind();", true);
     }
    }
Back to Top