Note that there are some explanatory texts on larger screens.

plurals
  1. POjqGrid not displaying data, no errors
    text
    copied!<p>OK, this mostly works as far as my PHP action is called and returns the JSON data from the query just fine. The problem is jqGrid won't display the data. What am I missing? I have read every article here and elsewhere on the subject I can find. This looks like it should work.</p> <p>HTML:</p> <pre><code>&lt;table id="dsisBaseTable"&gt;&lt;/table&gt; &lt;div id=dsisBasePager"&gt;&lt;/div&gt; </code></pre> <p>Here is my grid definition (the whole JavaScript function):</p> <pre><code>function runGridBaseReport() { $('#DSISBaseReportResult').html('&lt;table id="dsisBaseTable"&gt;&lt;/table&gt;' + '&lt;div id="dsisBasePager"&gt;&lt;/div&gt; '); $('#DSISBusy').fadeIn(); var loc = $('#dsisLocation').val(); var f = (loc == '') ? '' : loc.substring(0, 1); if (f.match(/[A-Z]/) || f.match(/[a-z]/)) loc = loc.substring(1); var dsisParams = { mode : 'basereport', dsisLocation : loc, dsisGuild : $('#dsisGuild').val(), dsisNick : $('#dsisNick').val(), dsisOccGuild : $('#dsisOccGuild').val(), dsisOccNick : $('#dsisOccNick').val(), dsisMinLevel : $('#dsisMinLevel').val(), dsisMaxLevel : $('#dsisMaxLevel').val(), dsisEconomy : $('#dsisEconomy').val(), dsisDt : $('#dsisDt').val(), dsisDs : $('#dsisDs').val(), dsisPr : $('#dsisPr').val(), dsisPs : $('#dsisPs').val(), dsisMinFleet : $('#dsisMinFleet').val(), dsisMaxFleet : $('#dsisMaxFleet').val(), dsisCapitol : $('#dsisCapitol').is(':checked'), dsisWormHole : $('#dsisWormHole').is(':checked'), dsisAeFormat : $('#dsisAeFormat').is(':checked') }; var data = { data: jsonString(dsisParams)}; $("#dsisBaseTable").jqGrid({ url: indexUrl + '/basereport', datatype: 'json', postData: data, mtype: 'POST', colNames:['Name', 'Location', 'WH', 'Inc', 'Eco', 'Guild', 'Owner', 'Level', 'Guild', 'OccBy', 'JG(Log)', 'CC', 'PH', 'DS', 'DT', 'PS', 'PR', 'DB', 'Fleet', 'Days', 'Updated By'], colModel :[ {name:'baseName', index:'baseName', sortable: false, width: 50, jsonmap: 'row.baseName'}, {name:'location', index:'location', width: 50, jsonmap: 'row.location'}, {name:'wh', index:'wh', width: 50, jsonmap: 'row.wormhole'}, {name:'inc', index:'inc', align:'right', width: 50, jsonmap: 'row.income'}, {name:'eco', index:'eco', align:'right', width: 50, jsonmap: 'row.economy'}, {name:'ownerGuild', index:'ownerGuild', width: 50, jsonmap: 'row.ownerGuild'}, {name:'ownerNick', index:'ownerNick', width: 50, jsonmap: 'row.ownerNick'}, {name:'ownerLevel', index:'ownerLevel', width: 50, jsonmap: 'row.ownerLevel'}, {name:'occGuild', index:'occGuild', width: 50, jsonmap: 'row.occGuild'}, {name:'occNick', index:'occNick', width: 50, jsonmap: 'row.occNick'}, {name:'jumpGate', index:'jumpGate', width: 50, jsonmap: 'row.jumpGate'}, {name:'commandCenter', index:'commandCenter', width: 50, jsonmap: 'row.commandCenter'}, {name:'photons', index:'photons', width: 50, jsonmap: 'row.photons'}, {name:'dshield', index:'dshields', width: 50, jsonmap: 'row.dshields'}, {name:'disruptors', index:'disruptors', width: 50, jsonmap: 'row.disruptors'}, {name:'pshields', index:'pshields', width: 50, jsonmap: 'row.pshields'}, {name:'prings', index:'prings', width: 50, jsonmap: 'row.prings'}, {name:'debris', index:'debris', width: 50, jsonmap: 'row.debris'}, {name:'fleetSize', index:'fleetSize', width: 50, jsonmap: 'row.fleetSize'}, {name:'daysOld', index:'daysOld', width: 50, jsonmap: 'row.daysOld'}, {name:'updatedBy', index:'updatedBy', sortable: false, width: 50, jsonmap: 'row.updatedBy'} ], pager: $('#dsisBasePager'), rowNum: $('#basePageSize').val(), rowList:[20,30,40,50], sortname: 'location', sortorder: 'asc', viewrecords: true, caption: 'Base Report', width: 1024, height: 300, jsonReader : { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "id" } }); /* pages' =&gt; round($totRows/$dsisPageSize), 'page' =&gt; $dsisPage, 'total' =&gt; $numRows/$dsisPage, 'records' =&gt; $totRows, 'rows' */ $('#DSISBusy').fadeOut(); $('#DSISBaseReportResult').fadeIn(); return false; } </code></pre> <p>This is how I process the request and return the results:</p> <pre><code>public function basereportAction() { try { $params = $this-&gt;_getAllParams(); //Log::logErr('params:'.print_r($params, true)); $data = $this-&gt;_getParam('data'); //Log::logErr('Data:'.print_r($data, true)); $reportParams-&gt;request = json_decode($data); //Log::logErr('DSIS Obj:'.print_r($obj, true)); $reportParams-&gt;request-&gt;dsisPage = $this-&gt;_getParam('page'); $reportParams-&gt;request-&gt;dsisPageSize = $this-&gt;_getParam('rows'); $reportParams-&gt;request-&gt;dsisOrderBy = $this-&gt;_getParam('sidx'); $reportParams-&gt;request-&gt;dsisSortDir = $this-&gt;_getParam('sord'); $base = new Base(); // $result is a PHP array $result = $base-&gt;outputDSISReportHtml($reportParams, true); $js = json_encode($result); Log::logErr('JSON:'.$js); $callback = $this-&gt;_getParam('callback'); echo $js; } catch( Exception $e) { Log::logErr('DSISReportController::basereport:Error:'.$e-&gt;getMessage()); throw $e; } } </code></pre> <p>This is my data:</p> <pre><code>{ "total": 0, "page": "1", "records": 1, "rows": [ { "id": 0, "row": { "baseName": "Stratos", "location": "J15:32:53:41", "wormhole": "", "income": 78, "economy": 78, "ownerGuild": "CDA", "ownerNick": "D-Day 9000", "ownerLevel": "17.14", "occGuild": "", "occNick": "", "jumpGate": 0, "commandCenter": 1, "photons": "0", "dshields": "0", "disruptors": "0", "pshields": "0", "prings": "0", "debris": 0, "fleetSize": "22250", "daysOld": 11, "updatedBy": 3057 } } ] } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload