This is a migrated thread and some comments may be shown as answers.
How to refresh RadGrid?
4 Answers 400 Views
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 17 Sep 2012, 02:30 PM
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"

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Sep 2012, 04:55 AM
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.
0
Dicky
Top achievements
Rank 1
answered on 18 Nov 2012, 04:16 PM
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?
0
Maria Ilieva
Telerik team
answered on 21 Nov 2012, 02:52 PM
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.
0
Waseem
Top achievements
Rank 1
answered on 04 Apr 2013, 06:39 PM
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
Tags
Ajax
Asked by
john
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Dicky
Top achievements
Rank 1
Maria Ilieva
Telerik team
Waseem
Top achievements
Rank 1
Share this question
or