This is a migrated thread and some comments may be shown as answers.

[Solved] Location.href does not refresh grid in IE

2 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
IQworks
Top achievements
Rank 1
IQworks asked on 05 Apr 2010, 05:08 AM
Hi,
    I am using an Ajax.BeginForm process that eventually returns to its OnComplete function to run ...
 function ChkComplete(content) {  
               
       try  
       {  
           var jsonData = content.get_response().get_object();  
             
           // In Update mode, if update is successfull, go to Grid page.  
           if (jsonData.OtherControllerUrl && jsonData.OtherControllerUrl.length > 0)   
           {  
  // This is what was sent from the controller ,,,,,,, 
  // return Json(new { OtherControllerUrl = "/Work/Index/?workindex=1&OtherParms=rebindGrid" });   
         
             location.href = jsonData.OtherControllerUrl;  // Returns refreshed grid in FireFox             
             return false;    
           }  
        }  
       catch (Error) {  
             
       }  
    
 In FireFox, the grid is returned with the updated data displaying.
 In IE, the grid is returned with the same data that it showed before the update, but, if you page forward and come back, then
the updated data is displayed. 

 This makes me think there needs to be a rebind or something just for IE. 
 
I found this post ......  

http://www.telerik.com/community/forums/aspnet-mvc/grid/problem-in-ie-when-using-partial-view.aspx 
This is how my MasterPage Scriptregistra looks ...

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
 
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>  
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> 
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> 
       
     
   
<!-- iqworks for telerik -->      
<%= Html.Telerik().StyleSheetRegistrar()                         
.DefaultGroup(group => group.Add("Work.css")                                                    
.Add("telerik.common.css")                                                      
.Add("telerik.hay.css")                                                     
.Combined(true)                                    
) %>   
 
</head> 
 
<body> 
    <div class="page">  
      
    <div> 
     <h1><%= Resources.BCAResources.mbxMemberNo%> : <%=Session["vdMemberNo"].ToString()%></h1>   
     <h1><%= Resources.BCAResources.stdBodyCompositionFor%>  :  <%= Session["vdDisplayName"].ToString()%></h1>  
 
    </div> 
      
     <div id="menucontainer">  
              
              <ul id="menu">                
                    <li><%= Html.ActionLink((string)Resources.BCAResources.stdHome, "Index", "Home")%></li>  
                    <li><%= Html.ActionLink((string)Resources.BCAResources.stdAbout, "About", "Home")%></li>  
                </ul>            
            </div> 
     
     <div id="main">  
            <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
              
              
              
     </div>         
            <div id="footer">  
        </div>      
            <%-- THE SCRIPTMANAGER - Either in the masterpage or in the child pages --%> 
           <%--  <%= Html.Telerik().ScriptRegistrar() %> --%> 
 <%= Html.Telerik().ScriptRegistrar()  
                   .DefaultGroup(group => group                       
                   .Add("jquery.validate.js")  
                   .Add("telerik.common.js")  
                   .Add("telerik.grid.js")  
                   .Add("telerik.grid.filtering.js")  
                   .Add("telerik.grid.editing.js")  
                   .Add("telerik.datepicker.min.js")  
                   .Add("telerik.calendar.min.js"))  
                            %> 
</body> 
</html> 
 

 During debug in FireFox, the code breaks at the masterpage, then, it breaks on the grid page, then the grid is displayed with the updated data.
 In IE, the debug breaks at the masterpage and then the grid just displays with the data that was suppose to be updated.

 I think I understood the post that describes the additions to the scriptregistrar, but I am thinking I am overlooking something else ?  is there something else I can include in the scriptregistrar (or anywhere) to evaluate the neccessary JS when running in IE ?

thanks as always for your time
 

    

2 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 05 Apr 2010, 08:39 AM
Hi,

You can try to re-bind the grid on the client, when the onComplete event is fired.
Use rebind() client method. You can also review this help topic devoted on the client-side api.

Regards,
Peter
0
IQworks
Top achievements
Rank 1
answered on 05 Apr 2010, 04:54 PM

 Hi Peter,
   
    Yes, I did try that ....  

function ChkComplete(content) {          
         
       try  
       {  
           var jsonData = content.get_response().get_object();  
                     
         if (jsonData.OtherControllerUrl && jsonData.OtherControllerUrl.length > 0)   
           {  
               location.href = jsonData.OtherControllerUrl;  
 
               var grid = $('#CompanyGrid').data('tGrid');  -- tried this
               grid.rebind();    
                  
               return false; // Ends the Ajax out of band cycle.  
           }  
        }  
       catch (Error) {  
             
       }  
     
    }  
 

     But in IE, debug (alert) says it cannot find the grid.
     In firefox, the debug gives a document.getElementById message, but, firefox goes on to display the proper, updated grid.  
     I tried the rebind both in the OnComplete and OnSuccess with the same results. 
    
    Since this only happens in IE, it seems like I need something in the scriptregistrar that can compensate for the lack of evaluation of the microsoft ajax  (as per the Telerik post link I refered to in my first post) ?

 thanks Peter

Tags
Grid
Asked by
IQworks
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
IQworks
Top achievements
Rank 1
Share this question
or