My jqgrid is working in Firefox 7 and IE9 but not in IE8 or Firefox 3.6.6. I am using latest version of jqgrid.
Here are the script files I've included:
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/ui-lightness/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/ui.jqgrid.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/ui.multiselect.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/ui-lightness/jquery-ui-1.8.16.custom.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/grid.locale-en.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/ui/minified/jquery.ui.core.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/ui/minified/jquery.ui.widget.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/ui/minified/jquery.ui.mouse.min.js")" type="text/javascript"></script>
This is my script in case if it's needed:
$(document).ready(function () {
$('#jobs').jqGrid({
url: '/SearchJob/Jobs/',
postData: {
'JobTitle': function () { return $('#JobTitle').val(); },
'City': function () { return $('#City').val(); },
'SelectJobType': function () { return $('#SelectJobType option:selected').val(); },
'SalaryStartRange': function () { return $('#SalaryStartRange').val(); },
'SalaryEndRange': function () { return $('#SalaryEndRange').val(); },
'SelectCategory': function () { return $('#SelectCategory option:selected').val(); },
'SelectIndustry': function () { return $('#SelectIndustry option:selected').val(); },
'CompanyName': function () { return $('#CompanyName').val(); },
'Keywords': function () { return $('#Keywords').val(); },
'SelectSalaryType': function () { return $('#SelectSalaryType option:selected').val(); }
},
datatype: 'json',
mtype: 'POST',
colNames: ['Title', 'Category', 'Company Name', 'Location', 'Salary Range', 'Date Posted'],
colModel: [
{ name: 'Title', index: 'title', width: 150, align: 'left', formatter: 'showlink', formatter: linkformatter },
{ name: 'Category', index: 'Category', width: 150, align: 'center' },
{ name: 'CompanyName', index: 'CompanyName', width: 150, align: 'center' },
{ name: 'CombinedLocation', index: 'CombinedLocation', width: 150, align: 'center' },
{ name: 'salaryRange', index: 'salaryRange', width: 150, align: 'center' },
{ name: 'DatePosted', index: 'DatePosted', width: 150, align: 'center' },
],
shrinkToFit: true,
rownumbers: true,
loadonce: false,
pager: jQuery('#jobPager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'jobid',
sortorder: "desc",
viewrecords: true,
imgpath: '',
caption: 'Jobs',
开发者_运维百科 width: '100%',
height: "100%"
});
$('#search').click(function () {
$('#jobs').trigger('reloadGrid');
return false;
});
});
linkformatter = function (cellValue, opts, rowObject) {
console.log(rowObject);
return "<a href='@Url.Action("JobView", "RecruiterProfile")/" + rowObject[rowObject.length - 1] + "'>" + cellValue + "<a/>";
}
Attached is the error that I get in IE8 and Firefox 3.6:
Removing screenshots because I am not allowed to post. If anybody drops here in future the error was of console. Removed in from my formatter function and it worked!
Update: The error only comes in Firefox 3.6 if I have disabled Firebug. I enable Firebug and everything works as expected. What am I doing wrong? Am I including the wrong script files?
I think you should write..
window.console.log(rowObject);
In place of
console.log(rowObject);
or you might get answer from here....
http://www.sitepoint.com/forums/showthread.php?575320-how-not-to-let-console.log%28%29-to-cause-error-on-IE-or-other-browsers
console.log(rowObject);
in IE8 or Firefox 3.6.6,It does not console object.It's will be working when you remove this.
You answerd almost yourself on your question in the last "Update" part: You have to test
if (window.console) {
window.console.log(rowObject);
}
or
if (console) {
console.log(rowObject);
}
because console
is not always exist.
精彩评论