How to refresh RadGrid?

5 posts, 0 answers
  1. john
    john avatar
    67 posts
    Member since:
    Jan 2012

    Posted 17 Sep 2012 Link to this post

    I have RadGrid with a add link. When click the add link it will pop up a RadWindow and load create.aspx page. When user click save button it will save data to DB and show successful information page. My question is how to refresh the RadGrid of parent page? My Code is as below:

    Pop Up page:
     function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow)
                    oWindow = window.radWindow;
                else if (window.frameElement.radWindow)
                    oWindow = window.frameElement.radWindow;
                return oWindow;
            }


            function refreshParent(info) {
                var oWindow = GetRadWindow();
                oWindow.BrowserWindow.refreshGrid(info);
            }

    Parent Page:
     function refreshGrid(info) {
                $find("<%= RadAjaxManager.ClientID %>").ajaxRequest(info);
            }

    <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" OnAjaxRequest="RadAjaxManager_AjaxRequest">.....

    In RadAjaxManager_AjaxRequest event, it will rebind the RadGrid.

    According my debugging, the RadAjaxManager_AjaxRequest is fired and RadGrid is bound. But the UI still don't show the updated data. Also, The Modal of RadWindow is set as "true"
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Sep 2012 Link to this post

    Hi John,

    Try the following code snippet to rebind the RadGrid.

    parent page

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
      <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>

    JS:
    <script type="text/javascript">
        function refreshGrid(info) {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("info");
        }
    </script>

    C#:
    protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
          RadGrid1.MasterTableView.SortExpressions.Clear();
          RadGrid1.MasterTableView.GroupByExpressions.Clear();
          RadGrid1.Rebind();
        }

    PopUp Page

    JS:
    <script type="text/javascript">
        function refreshParent(info) {
            GetRadWindow().BrowserWindow.refreshGrid(info);
        }
      
        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;
        }
    </script>

    Please take a look into this demo for more information.

    Please provide your full code if it doesn't helps.

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dicky
    Dicky avatar
    7 posts
    Member since:
    Mar 2010

    Posted 18 Nov 2012 Link to this post

    Hi Shinu,

    I have similar case with what discussed here, but I have another condition, I have 2 RadGrid let say RadGrid1 and RadGrid2, and I have these settings :

    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="LoadingPanel1"  />
           <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="LoadingPanel2"  /> 
            </UpdatedControls>
         </telerik:AjaxSetting>

    Problem is if I refresh the RadGrid1, with what you suggested here, the LoadingPanel1 and LoadingPanel2 will show up. I'm expecting only the LoadingPanel1 that show up. Could you give your suggestion?
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 21 Nov 2012 Link to this post

    Hello Dicky,

    Try using the following settings:
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadGrid1"   />
               <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
            </UpdatedControls>
         </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="LoadingPanel1"  />
            </UpdatedControls>
         </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="RadGrid2">
            <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="LoadingPanel2"  />
            </UpdatedControls>
         </telerik:AjaxSetting>


    Regards,
    Maria Ilieva
    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.
  6. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 04 Apr 2013 Link to this post

    hi Shinu,

    I want to refresh full page when dropdown selectedindex is changed. Like ddlCategory is my dropdown , i want to refresh full page on that place and other events i don't want to refresh as mention. Can you help me in this?

            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest">
                <ajaxsettings>  
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">              
                        <UpdatedControls>  
                            <telerik:AjaxUpdatedControl ControlID="gvRecommendations" />                      
                        </UpdatedControls>  
                    </telerik:AjaxSetting>              
                    
                    <telerik:AjaxSetting AjaxControlID="gvRecommendations">              
                        <UpdatedControls>  
                            <telerik:AjaxUpdatedControl ControlID="gvRecommendations" />
                            <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />                     
                        </UpdatedControls>  
                    </telerik:AjaxSetting>    
                  

                    <telerik:AjaxSetting AjaxControlID="ddlCategory">              
                        <UpdatedControls>  
                         
                        </UpdatedControls>  
                    </telerik:AjaxSetting>

                              
                </ajaxsettings>
            </telerik:RadAjaxManager>

    Thanks,
    the telerik team
    Muhammad Waseem
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017