Reputation: 377
I have a jqGrid in my asp.net mvc 4 view and in this view I define a type that will be used for the jqGrid. The jqGrid is within a jQuery Tab (I have a jQuery tab component).
The jqGrid in the tab is inserted as follows:
<div id="jqGrid">
@Html.Partial("../Grids/_MyGrid")
</div>
this is called from an ajax call in the same view as follows:
@using (Ajax.BeginForm("Search", "Item",
new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "jqGrid",
OnSuccess = "showGridItems()"
}))
{
// My Stuff
}
in the same view i have defined a type that will be used for the jqGrid as follows:
<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>
The partial view _MyGrid above indicated looks like the following also in the same view:
<table id="_itemGrid" cellpadding="0" cellspacing="0">
</table>
<div id="_itemPager" style="text-align: center;">
</div>
When the ajax call is executed (see above ajax code) and the result is success, below javascript function is called onsuccess:
function showGridItems() {
$('#_itemGrid').jqGrid({
caption: paramFromView.Caption,
colNames: ['ID', paramFromView.ItemName, paramFromView.ItemAddress, paramFromView.ItemType, paramFromView.Actions],
colModel: (...)
}
This function is defined in a js file and it is included in the same view as below:
@section scripts
{
@Content.Script("/Grids/ItemGrid.js", Url)
}
It is working perfectly in IE8, IE9 and IE10 but in IE7 it crashes in the showGridItems. The error is saying that paramFromView is not defined! I do not know why because from IE8 to IE10 is working perfectly but not for IE7. What's happening?
UPDATED It was caused by the comma after the pageSize. I have removed and now works.
Upvotes: 0
Views: 155
Reputation: 3339
Remove the last comma (,) from the script.
<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
};
Upvotes: 1