Note that there are some explanatory texts on larger screens.

plurals
  1. POThe pager is not working as expected in jqGrid with a JSON
    text
    copied!<p>I have a question about jqGrid and Json.</p> <p>This is the code of my jsp file with the code of Jquery:</p> <pre><code> &lt;body &gt; &lt;script type="text/javascript"&gt; jq(function() { jq("#grid").jqGrid({ url:'/test-security-client/crud', datatype: 'json', mtype: 'GET', colNames:['Id', 'Log Message'], colModel:[ {name:'id',index:'id', width:55,editoptions:{readonly:true,size:10},hidden:true}, {name:'logMsg',index:'logMsg', width:300,editable:true, editrules:{required:true}, editoptions:{size:10}} ], rowNum:20, rowList:[20,40,60], height: 450, autowidth: true, rownumbers: true, pager: '#pager', sortname: 'id', viewrecords: true, sortorder: "asc", caption:"Error Logs", emptyrecords: "Empty records", loadonce: false, loadComplete: function() { }, jsonReader : { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, cell: "cell", id: "id" } }); jq("#grid").jqGrid('navGrid','#pager', {edit:false,add:false,del:false,search:false}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true } ); jq("#grid").navButtonAdd('#pager', { caption:"Delete", buttonicon:"ui-icon-trash", onClickButton: deleteRow, position: "last", title:"", cursor: "pointer" } ); jq("#btnFilter").click(function(){ jq("#grid").jqGrid('searchGrid', {multipleSearch: false, sopt:['eq']} ); }); }); &lt;/script&gt; ... </code></pre> <p>And this is the JSON that I am sending:</p> <pre><code>{"total":"2","page":"1","records":"28","rows":[{"id":1,"logMsg":"ID of log:1-Requesting authentication. (SMA/SmaAdmin/password)"},{"id":2,"logMsg":"ID of log:2-Authentication received."},{"id":3,"logMsg":"ID of log:3-Test"},{"id":4,"logMsg":"ID of log:4-Test 2"},{"id":5,"logMsg":"ID of log:5-Test 3"},{"id":6,"logMsg":"ID of log:6-Test 4"},{"id":7,"logMsg":"ID of log:7-Test 5"},{"id":8,"logMsg":"ID of log:8-Test 6"},{"id":9,"logMsg":"ID of log:9-Test 7"},{"id":10,"logMsg":"ID of log:10-Test 8"},{"id":11,"logMsg":"ID of log:11-Test 9"},{"id":12,"logMsg":"ID of log:12-Test 10"},{"id":13,"logMsg":"ID of log:13-Test 11"},{"id":14,"logMsg":"ID of log:14-Test 12"},{"id":15,"logMsg":"ID of log:15-Test 13"},{"id":16,"logMsg":"ID of log:16-Test 14"},{"id":17,"logMsg":"ID of log:17-Test 15"},{"id":18,"logMsg":"ID of log:18-Test 16"},{"id":19,"logMsg":"ID of log:19-Test 17"},{"id":20,"logMsg":"ID of log:20-Test 18"},{"id":21,"logMsg":"ID of log:21-Test 19"},{"id":22,"logMsg":"ID of log:22-Test 20"},{"id":23,"logMsg":"ID of log:23-Test 21"},{"id":24,"logMsg":"ID of log:24-Test 22"},{"id":25,"logMsg":"ID of log:25-Test 23"},{"id":26,"logMsg":"ID of log:26-Test 24"},{"id":27,"logMsg":"ID of log:27-Test 25"},{"id":28,"logMsg":"ID of log:28-Test 26"}]} </code></pre> <p>HERE IS MY QUESTION: This code is working, the jqgrid is well displayed, all the information is comming well. BUT the pager is not working well. Because, I can't move between pages. (I have 2 pages, and I start the jqGrid in the page number 1.. but I cant go to the number 2).</p> <p>If I change the property loadonce to true.. then Is working. But I dont want to use this property, and all the records are comming in wrong positions.</p> <p>As I understand the JSON is right, and the code is right, I dont know what I am doing wrong. (I am new to jqGrid and JQuery). I guess that I have one kind of problem with the pager.</p> <p>Any idea of what I am doing wrong? Do I have to send a Json with the information of each page?</p>
 

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