0

最近,我在使用 jqGrid 来表示我的业务数据集,我发现 jqGrid 有编辑/添加/删除/查看功能,所以我尝试使用它。但是我遇到了一个问题,我尽力而为后无法解决。

我按照本网站的示例进行操作:

jQuery("#deptGrid").jqGrid('navGrid', '#deptNav', {
    view : true
}, 
{
    jqModal : true,
    checkOnUpdate : true,
    savekey : [ true, 13 ],
    navkeys : [ true, 38, 40 ],
    checkOnSubmit : true,
    reloadAfterSubmit : false,
    closeOnEscape : true,
    bottominfo : "Fields marked with (*) are required"
}, {
    jqModal : true,
    checkOnUpdate : true,
    savekey : [ true, 13 ],
    navkeys : [ true, 38, 40 ],
    checkOnSubmit : true,
    reloadAfterSubmit : false,
    closeOnEscape : true,
    bottominfo : "Fields marked with (*) are required"
}, {
    reloadAfterSubmit : false,
    jqModal : false,
    closeOnEscape : true
}, {
    closeOnEscape : true
}, {
    navkeys : [ true, 38, 40 ],
    height : 250,
    jqModal : false,
    closeOnEscape : true
});

更新:以下是我的全部内容:

<link rel="stylesheet" type="text/css" href="<%=BASE_PATH %>admin/styles/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="<%=BASE_PATH %>admin/js/jquery/ui/themes/ui-lightness/ui.all.css" />

<link rel="stylesheet" type="text/css" media="screen" href="<%=BASE_PATH %>jqGrid4.4.1/themes/redmond/jquery-ui-1.8.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=BASE_PATH %>jqGrid4.4.1/themes/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=BASE_PATH %>jqGrid4.4.1/themes/ui.multiselect.css" />

<!-- Including JS -->
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/superfish/js/superfish.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/tab.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/global.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/thickbox/thickbox.js"></script>
<link  rel="stylesheet" type="text/css" href="<%=BASE_PATH %>admin/js/jquery/thickbox/thickbox.css" />
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/jquery.form.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/jquery.validate.js"></script>
<script type="text/javascript" src="<%=BASE_PATH %>admin/js/jquery/jquery-ui-timepicker-addon.js"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.core.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.widget.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.button.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.position.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.resizable.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.ui.dialog.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>admin/js/jquery/ui/jquery.effects.core.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>js/kevinshi.js" type="text/javascript"></script>

<script src="<%=BASE_PATH %>jqGrid4.4.1/js/jquery.jqGrid.src.js" type="text/javascript"></script>
<script src="<%=BASE_PATH %>jqGrid4.4.1/js/i18n/grid.locale-en.js" type="text/javascript"></script>

更新:每当我单击按钮进行编辑/添加/删除时,它总是会在萤火虫中导致错误:

$.type is not a function 
var obj = $.type( pref );

我将其跟踪到 jqGrid 源代码中,此错误发生在文件的第 52 行,jquery.jqGrid.src.js如下所示:

stripPref : function (pref, id) {
var obj = $.type( pref ); // Happened at this line.
if( obj == "string" || obj =="number") {
pref = String(pref);
id = pref !== "" ? String(id).replace(String(pref), "") : id;
}
return id;
}, 

所以,就在这一刻,我可以说jQuery.type()方法找到了,但是我已经包含了 library jquery.min.js,我很困惑。

4

3 回答 3

0

将两个 JavaScript 文件多次包含在同一个模块的实现中是错误的。此外,以正确的顺序包含 JavaScript 文件也很重要。此外,您不应包含任何您不使用的插件。

通常一种用途

i18n/grid.locale-en.js
jquery.jqGrid.src.js

在开发一些解决方案和使用过程中

i18n/grid.locale-en.js
jquery.jqGrid.min.js

在最终解决方案中。请参阅文档

应该在任何 jqGrid JavaScript 文件之前包含 jQuery 。ui.jqgrid.css还需要包括 of和 jQuery UI CSS。

如果您仍然有错误,您应该发布jquery.jqGrid.src.js错误发生位置的确切行号。您应该发布您使用的更完整的 JavaScript 代码。

于 2013-01-05T13:32:14.980 回答
0

I just encountered the exact same error message. I'm posting what worked for me in case it might help anyone else. I was getting the TypeError: b.type is not a function when trying to save from a form. The version of jqgrid I am using is 4.4.3, and I was calling an older version of jquery (1.4.2). Using a newer version of jquery (1.7.2 in my case) fixed the problem. I guess the function 'type' was not in version 1.4.2.

于 2013-04-04T21:31:48.733 回答
0

解决了这个问题。只是因为jqGrid不支持jQuery 1.9

于 2013-07-02T04:37:17.513 回答