jqgrid过滤器工具栏无法正常工作

时间:2013-03-06 15:03:28

标签: java jquery jqgrid

我正在尝试在jqgrid中实现过滤器工具栏。 但每当我在任何一个过滤器工具栏搜索框中输入任何内容时,“加载”弹出窗口就会停留在那里,然后什么都不会发生。以下是快照:

The Error

以下是我的jqgrid代码:

    jQuery(document).ready(function($) {

    $('#workQueueGrid').jqGrid('GridDestroy');
    $("#workQueueGrid").jqGrid({
        url:contextRoot+'workQueueGrid',
        datatype: 'json',
        mtype: 'POST',
        colNames: ['ID','Received','Last Name','First Name','Aa','Bbbb', 'Source', 'Ddddd', 'Ccccc', 'Eeeeee', 'Fffffff', 'Ggggggg', 'Hhhhhhh'],
        colModel: [
                   { name: 'Id', 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: 'data1', index: 'data1', width: 30, sortable:true },
                   { name: 'data2', index: 'data2', width: 30, sortable:true },
                   { name: 'data3', index: 'data3', width: 40, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
                   { name: 'data4', index: 'data4', width: 30, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
                   { name: 'data5', index: 'data5', width: 40, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } },
                   { name: 'data6', index: 'data6', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
                   { name: 'data7', index: 'data7', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
                   { name: 'data8', index: 'data8', width: 50, formatter: function(cellValue){return $.datepicker.formatDate('mm-dd-yy', new Date(cellValue));}, sortable:true },
                   { name: 'data9', index: 'data9', width: 80, sortable:true, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal;"'; } }
        ],loadError: function(xhr,st,err) {
            alert(err);
        },onSelectRow : function(rowid, status, e) {
            var selRow = $(this).getGridParam("selrow");
            var selReferralId = $(this).getCell(selRow, 'referralId');
            window.location = (contextRoot+"referralDetails?refId=" + selReferralId );            
        },
        jsonReader: {
            repeatitems: false,
        },
        pager: '#workQueuePager',
        sortname: 'receivedDate',
        sortorder: 'desc',
        gridview: true,
        viewrecords: true,
        loadonce: true,
        autowidth: true,
        shrinkToFit: true,
        height: 'auto',
        rowNum: 12,
        ignoreCase: true,
        altRows:true
    }); 

    $("#workQueueGrid").jqGrid('navGrid','#workQueuePager',
       {
        edit:false,
        add:false,
        del:false,
        search:false,
        refresh:false
    });

    $("#workQueueGrid").jqGrid('filterToolbar',
        { 
         stringResult: true, 
         searchOnEnter: false,
         defaultSearch: "bw"
    });
});

示例数据:

    {"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"},

不确定,我在这里缺少什么?!?

更新1:

Below is the error I'm getting:

Uncaught TypeError: Cannot call method 'getAccessor' of undefined

更新2

以下是JSP:

    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <script type="text/javascript"  src="<c:url value="/js/workQueue.js"/>"></script>
    <style type="text/css">
        th.ui-th-column div {
          white-space:normal !important;
          height:auto !important;
          padding:2px;
     }  
    </style>    
</head>
<body>
    <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>
</body>
</html>

这是Handler方法:

        @RequestMapping(method = RequestMethod.POST, value = "/workQueueGrid") 
    @ResponseBody 
    public JqgridResponse loadWorkQueue() {
        this.referrals = dartService.getReferralCases(status);       
        JqgridResponse response = new JqgridResponse();
        response.setRows(referrals);

        return response;
    }

这是JqgridResponse.java:

    package com.nyl.corp.disciplinaryactions.web;

import java.util.List;

public class JqgridResponse {

    public JqgridResponse(List<?> rows) {
        this.rows = rows;
    }

    public JqgridResponse() {
    }

    private List<?> rows;

    private int page;

    private int total;

    private int records;

    public void setRows(List<?> rows) {
        this.rows = rows;
    }

    public List<?> getRows() {
        return rows;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getRecords() {
        return records;
    }

    public void setRecords(int records) {
        this.records = records;
    }

}

更新3 标签内网格的快照:

enter image description here enter image description here

更新4 选项卡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>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。在文件jquery.jqGrid.js中,

它通过jQuery调用jQuery。看起来您的设置无法通过这种方式识别它。尝试改变jQuery。到$。文件中到处都是。

它对我有用。

未捕获TypeError:无法调用未定义的方法'getAccessor'(它不理解jQuery。但它确实是$。)