我在这里面临一个奇怪的问题。
我将jqGrids放在jQuery选项卡中。以下是快照:
我正在尝试在jqgrid中实现过滤器工具栏。但每当我在任何一个过滤器工具栏搜索框中输入任何内容时,“加载”弹出窗口就会停留在那里,然后什么都不会发生。以下是快照:
在IE中,它给出了错误:
jQuery.jgrid为null或不是对象
在Chrome中,错误显示:
未捕获的TypeError:无法调用未定义的方法'getAccessor'
当我删除标签时,filtertoolbar功能正常。 jqGrid filtertoolbar和jQuery标签之间是否有任何问题。
更新1
选项卡JSP代码:
<script>
$(function() {
$( "#workQueuesTab" ).tabs();
});
</script>
</head>
<body>
<div style="width:95%" id="workQueuesTab">
<ul>
<li><a href="<c:url value="/workQueue/pending"/>">Pending</a></li>
<li><a href="<c:url value="/workQueue/approved"/>">Approved</a></li>
<li><a href="<c:url value="/workQueue/additionalSteps"/>">Additional Steps</a></li>
</ul>
</div>
</body>
网格JSP代码:
<table width="100%">
<tr>
<td>
<span style="font-size: 18px"><b>${status == 'pending' ? 'Pending': 'Approved'}</b></span><br/><br/>
There are ${workQueueCount} referrals ${status}. Click a row to see details.<a href="<c:url value="/excelExport"/>" id="excelExport" style="float: right;">Export To Excel</a>
</td>
</tr>
<tr height="5px">
<td>
</td>
</tr>
<tr>
<td>
<table id="dartWorkQueueGrid"></table>
<div id="dartWorkQueuePager"></div>
</td>
</tr>
</table>
网格Javascript代码:
jQuery(document).ready(function($) {
$('#dartWorkQueueGrid').jqGrid('GridDestroy');
$("#dartWorkQueueGrid").jqGrid({
url:contextRoot+'workQueueGrid',
datatype: 'json',
jsonReader: {repeatitems: false},
mtype: 'POST',
colNames: ['ID','Received','Last Name','First Name','GO','Zone', 'Source', 'Status', 'AS Action', 'VP Report', 'Approved', 'Last Modified', 'Workflow'],
colModel: [
{ name: 'referralId', index: 'referralId', width: 30, sortable:true },
{ name: 'receivedDate', index: 'receivedDate', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
{ name: 'lastName', index: 'lastName', width: 55, sortable:true },
{ name: 'firstName', index: 'firstName', width: 55, sortable:true },
{ name: 'goCode', index: 'goCode', width: 30, sortable:true },
{ name: 'zoneCode', index: 'zoneCode', width: 30, sortable:true },
{ name: 'sourceName', index: 'sourceName', width: 40, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
{ name: 'status', index: 'status', width: 40, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
{ name: 'actionAS', index: 'actionAS', width: 30, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
{ name: 'vpReportDate', index: 'vpReportDate', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
{ name: 'approvedDate', index: 'approvedDate', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
{ name: 'lastModifiedDate', index: 'lastModifiedDate', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
{ name: 'workflow', index: 'workflow', width: 80, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } }
],loadError: function(xhr,st,err) {
alert(err);
},loadComplete: function (data) {
var $this = $(this),
datatype = $this.getGridParam('datatype');
if (datatype === "xml" || datatype === "json") {
setTimeout(function () {
$this.trigger("reloadGrid");
}, 10);
}
},onSelectRow : function(rowid, status, e) {
var selRow = $(this).getGridParam("selrow");
var selReferralId = $(this).getCell(selRow, 'referralId');
window.location = (contextRoot+"referralDetails?refId=" + selReferralId );
},
pager: '#dartWorkQueuePager',
sortname: 'receivedDate',
sortorder: 'desc',
gridview: true,
viewrecords: true,
loadonce: true,
autowidth: true,
shrinkToFit: true,
height: 'auto',
rowNum: 12,
ignoreCase: true,
altRows:true
});
$("#dartWorkQueueGrid").jqGrid('navGrid','#dartWorkQueuePager',
{
edit:false,
add:false,
del:false,
search:false,
refresh:false
});
$("#dartWorkQueueGrid").jqGrid('filterToolbar',
{
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
});
JS的顺序包括:
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="<c:url value="/css/ui.jqgrid.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/css/home.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/css/styles-nyl.css"/>" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js"></script>
<script type="text/javascript" src="<c:url value="/js/shared/grid.locale-en.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/shared/jquery.jqGrid.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/shared/json2.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/shared/jquery.loadJSON.js"/>"></script>
示例数据
{"rows":[{"receivedDate":1357016400000,"referralId":23450,"lastName":"Smith","firstName":"John","goCode":"A99","zoneCode":"NE","sourceName":"Source Name","status":"Pending","actionAS":"AS Action","vpReportDate":1357016400000,"approvedDate":1357016400000,"lastModifiedDate":1357016400000,"workflow":"Recommendation(s) required"},{"receivedDate":1357102800000,"referralId":23451,"lastName":"Smith","firstName":"John","goCode":"A99","zoneCode":"NE","sourceName":"Source Name","status":"Pending","actionAS":"AS Action","vpReportDate":1357102800000,"approvedDate":1357102800000,"lastModifiedDate":1357102800000,"workflow":"Recommendation(s) required"},{"receivedDate":1357189200000,"referralId":23452,"lastName":"Smith","firstName":"John","goCode":"A99","zoneCode":"NE","sourceName":"Source Name","status":"Pending","actionAS":"AS Action","vpReportDate":1357189200000,"approvedDate":1357189200000,"lastModifiedDate":1357189200000,"workflow":"Recommendation(s) required"},
我已经坚持这个问题好几天了,无处可去。非常感谢任何帮助!
答案 0 :(得分:1)
错误
jQuery.jgrid为null或不是对象
主要是指您以错误的顺序包含了jqGrid(i18n/grid.locale-en.js
和jquery.jqGrid.min.js
或jquery.jqGrid.src.js
)或jQuery JavaScript文件所需的JavaScripts。您应该将您的代码与jqGrid文档中的the example进行比较。
此外,我建议您始终包含您使用的jQuery,jQuery UI和jqGrid的确切版本号。您应该使用jquery.jqGrid.src.js
(而不是jquery.jqGrid.min.js
)进行测试,并将错误的行号发布。
更新:抱歉,我无法重现您描述的问题。见the demo。您可以将演示的来源与青少年进行比较。可能你有更多的差异,你没有包含在问题的文本中。