1

I'm facing a weird problem here.

I've jqGrids placed inside the jQuery tabs. Below is the snapshots:

enter image description here enter image description here

I'm trying to implement the filter toolbar in my jqgrid. But whenever I enter anything in any one of the filter toolbar search box, the "Loading" pop-up comes and stays there and nothing happens then. Below is the snapshot:

enter image description here

In IE it gives the error:

jQuery.jgrid is null or not an object

In Chrome the error says:

Uncaught TypeError: Cannot call method 'getAccessor' of undefined

When I remove the tabs, the filtertoolbar functionality works fine. Is there any issue between jqGrid filtertoolbar and jQuery tabs.

Update 1

Tabs JSP code:

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

Grid JSP code:

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

Grid Javascript code:

    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"
    });
});

Order of the JS includes:

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

Sample Data

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

I'm stuck with this problem for days now and heading nowhere. any help is deeply appreciated!

tarares
  • 392
  • 4
  • 10
  • 27
  • This may help you http://stackoverflow.com/questions/5094259/multiple-jqgrids-in-jqueryui-tabs Otherwise, please post your jQuery Code – user1477388 Mar 11 '13 at 15:08
  • @user1477388 Thanks for the comment! I saw the post and it describes about multiple grids under tabs not loading. I had that issue sometime back but I resolved it. My issue is that grids load but the filtertoolbar on the grids doesn't work. – tarares Mar 11 '13 at 15:24
  • Without seeing your jQuery we can only guess https://www.google.com/search?q=jqdrid+filter+not+working&aq=f&oq=jqdrid+filter+not+working&aqs=chrome.0.57j0l3.6132&sourceid=chrome&ie=UTF-8 – user1477388 Mar 11 '13 at 15:27
  • @user1477388 I've updated my question with the code details. – tarares Mar 11 '13 at 15:31
  • 1
    @tarares: Do you really includes `jquery-ui.min.js` twice? – Oleg Mar 11 '13 at 15:46
  • @Oleg My bad! I didn't realize that! I deleted the extra include. But the error still persists. – tarares Mar 11 '13 at 15:53

1 Answers1

1

The error

jQuery.jgrid is null or not an object

means mostly that you included JavaScripts required for jqGrid (i18n/grid.locale-en.js and jquery.jqGrid.min.js or jquery.jqGrid.src.js) or jQuery JavaScript file in the wrong order. You should compare your code with the example from jqGrid documentation.

Additionally I recommend you always include exact version number of jQuery, jQuery UI and jqGrid which you use. You should make your tests with jquery.jqGrid.src.js (not with jquery.jqGrid.min.js) and post the line number of the error.

UPDATED: Sorry, but I can't reproduce the problem which you describe. See the demo. You can compare the source of the demo with youth one. Probably you have some more differences which you don't included in the text of the question.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg! Thanks a lot for your time! I've updated my question with the order of the js includes. – tarares Mar 11 '13 at 15:40
  • @tarares: Please answer on the questions: 1) which versions of jQuery, jQuery UI and jqGrid you use? 2) in which line number of `jquery.jqGrid.src.js` the error "jQuery.jgrid is null or not an object" pake place? 3) in which order you includes `grid.locale-en.js`, `jquery.jqGrid.src.js` and other JS-files on the page which has the error. – Oleg Mar 11 '13 at 15:43
  • Please find below my answers: 1) I use the following versions: jQuery: 1.8.3 jQuery UI: 1.9.2 jqGrid: 4.4.1 2) I'm getting the error in line: **(String(jQuery.jgrid.getAccessor(this,'referralId')).toLowerCase().indexOf("1",‌​0) > -1)** 3) I've updated the question with JS-files include order. – tarares Mar 11 '13 at 16:09
  • @tarares: Could you include test JSON data which can be used to reproduce the problem? – Oleg Mar 12 '13 at 07:47
  • Could you get time to look into my issue. I'm still stuck with this. – tarares Mar 15 '13 at 14:14
  • 1
    @tarares: I am asked to help by answering on questions from many people. I have to make my main job too (which bring me and my family money :-)). I'll came to your question later after I'll finish some other things which I am doing currently. – Oleg Mar 15 '13 at 18:17
  • @tarares: Sorry, but I can't reproduce the problem. See **UPDATED** part of my answer with the demo. – Oleg Mar 20 '13 at 06:52
  • Thanks a lot for your time and creating a Demo for the same. After comparing the code of your demo and my code, I see the difference in versions and files of jquery and jqgird. May be that might be an issue. Will try to play with the versions and see if that works! – tarares Mar 20 '13 at 14:39
  • 1
    @tarares: You are welcome! I'm not sure that the versions jQuery, jQuery UI etc is the origin of the problem. More I think that the reason are the data which you used. In any way I would recommend you to specify `id` of rows in the input data. You can just add `key: true` property to the definition of `referralId` column. One can use also `jsonReader: {repeatitems: false, id: "referralId"}`. I recommend you to define `sorttype` in `colModel` if the content is not text. Usage of column `templates` (see [here](http://stackoverflow.com/a/6047856/315935)) could improve your code too. – Oleg Mar 20 '13 at 14:52
  • Changing of the versions of the files did the trick! Oh..I can't tell how relieved I'm feeling now! Thanks a lot for all your help! – tarares Mar 22 '13 at 17:58
  • 1
    @tarares: All's Well that ends well! I'm glad that I could help you. You are welcome! – Oleg Mar 22 '13 at 18:17