2013-10-06 28 views
0

我在我的asp.net mvc 4视图中有一个jqGrid,并且在这个视图中我定义了一个将用于jqGrid的类型。 jqGrid在一个jQuery选项卡(我有一个jQuery选项卡组件)。当调用javascript函数时,IE 7崩溃

的的jqGrid在突片插入如下:

<div id="jqGrid"> 
     @Html.Partial("../Grids/_MyGrid") 
    </div> 

这是从在相同的视图中的AJAX调用称为如下:

@using (Ajax.BeginForm("Search", "Item", 
    new AjaxOptions 
    { 
     HttpMethod = "GET", 
     InsertionMode = InsertionMode.Replace, 
     UpdateTargetId = "jqGrid", 
     OnSuccess = "showGridItems()" 
    })) 
{ 
    // My Stuff 
} 

在同一视图中我已经定义了一个将用于jqGrid的类型如下:

<script type="text/javascript"> 
    var paramFromView = { 
     DeleteAllCaption: '@Resource.CaptionPagerDeleteAll', 
     ClearGridUrl: '@Url.Content("~/Item/ClearGridData")', 
     DeleteAllConfirmationMessage: '@Resources.Resource.ItemDeleteAllDataConfirmation', 
     Url: '@Url.Content("~/Item/GetData")', 
     Width: @width, 
     Height: @height, 
     Caption: '@Resources.Resource.ItemIndexTitle', 
     ItemName: '@Resources.Resource.ItemIndexName', 
     ItemAddress: '@Resources.Resource.ItemIndexAddress', 
     ItemType: '@Resources.Resource.ItemIndexType', 
     Actions: '@Resources.Resource.ItemIndexActions', 
     PageSize: @pageSize, 
    }; 

</script> 

上面的局部视图_MyGrid表示d看起来像下文中也以相同的视图:

<table id="_itemGrid" cellpadding="0" cellspacing="0"> 
</table> 
<div id="_itemPager" style="text-align: center;"> 
</div> 

当执行AJAX调用(见上文AJAX代码),其结果是成功,下面的javascript函数被调用的onSuccess:

function showGridItems() { 
    $('#_itemGrid').jqGrid({ 
     caption: paramFromView.Caption, 
     colNames: ['ID', paramFromView.ItemName, paramFromView.ItemAddress, paramFromView.ItemType, paramFromView.Actions], 
     colModel: (...) 
} 

该函数在一个js文件中定义,它包括在如下面相同的视图:

@section scripts 
{ 
    @Content.Script("/Grids/ItemGrid.js", Url) 
} 

它正常使用中IE8,IE9和IE10但在IE7它在showGridItems崩溃。错误是说paramFromView没有被定义!我不知道为什么,因为从IE8到IE10是完美的,但不适用于IE7。发生了什么?

UPDATED 这是由pageSize之后的逗号引起的。我已经删除,现在工作。

回答

1

从脚本中删除最后一个逗号(,)。

<script type="text/javascript"> 
var paramFromView = { 
    DeleteAllCaption: '@Resource.CaptionPagerDeleteAll', 
    ClearGridUrl: '@Url.Content("~/Item/ClearGridData")', 
    DeleteAllConfirmationMessage: '@Resources.Resource.ItemDeleteAllDataConfirmation', 
    Url: '@Url.Content("~/Item/GetData")', 
    Width: @width, 
    Height: @height, 
    Caption: '@Resources.Resource.ItemIndexTitle', 
    ItemName: '@Resources.Resource.ItemIndexName', 
    ItemAddress: '@Resources.Resource.ItemIndexAddress', 
    ItemType: '@Resources.Resource.ItemIndexType', 
    Actions: '@Resources.Resource.ItemIndexActions', 
    PageSize: @pageSize 
}; 

+0

是的,这就是问题所在;) – Rodri

+0

@Satpal你说什么? – Dvir

+0

@Dvir,伟大和接受我希望+1会很好 – Satpal

相关问题