jqgrid 无法在 IE8 和 Firefox 3.6.6 中工作

发布于 2024-12-07 18:28:29 字数 4479 浏览 0 评论 0 原文

我的 jqgrid 在 Firefox 7 和 IE9 中工作,但在 IE8 或 Firefox 3.6.6 中不起作用。我正在使用最新版本的 jqgrid。

以下是我包含的脚本文件:

  <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>

这是我的脚本,以防需要时使用:

 $(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/>"; 
    }

附件是我在 IE8 和 Firefox 3.6 中遇到的错误:

正在删除屏幕截图,因为不允许我发帖。如果将来有人掉到这里,错误就是控制台的。从我的格式化程序功能中删除,它起作用了!

更新:如果我禁用了 Firebug,则该错误仅出现在 Firefox 3.6 中。我启用了 Firebug,一切都按预期工作。我做错了什么?我是否包含了错误的脚本文件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

诠释孤独 2024-12-14 18:28:29

我认为你应该写..

window.console.log(rowObject);

代替

console.log(rowObject);

或者你可能会从这里得到答案....

http://www.sitepoint.com/forums/showthread.php?575320-how-not-to-let-console.log%28%29-to-cause-error-on-IE-或其他浏览器

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

献世佛 2024-12-14 18:28:29
 console.log(rowObject);

在 IE8 或 Firefox 3.6.6 中,它没有控制台对象。当你删除它时,它将起作用。

 console.log(rowObject);

in IE8 or Firefox 3.6.6,It does not console object.It's will be working when you remove this.

亚希 2024-12-14 18:28:29

您在最后一个“更新”部分中几乎自己回答了您的问题:您必须测试

if (window.console) {
    window.console.log(rowObject);
}

if (console) {
    console.log(rowObject);
}

因为 console 并不总是存在。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文