我的asp.net mvc 4视图中有一个asp.net,在这个视图中,我定义了一种将用于jqGrid的类型。jqGrid位于jQuery选项卡中(我有一个jQuery选项卡组件)。
选项卡中的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也在相同的视图中类似于以下内容:
<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却不起作用。发生什么事了呢?
更新了,它是由pageSize后面的逗号引起的。我已经搬走了,现在开始工作了。
发布于 2013-10-06 18:06:04
从脚本中删除最后一个逗号(,)。
<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
};
https://stackoverflow.com/questions/19212064
复制相似问题