JqGrid - pagination not working properly

As you can see in this image

enter image description here

I have 13 entries in my database, but the pager says that it has only 1 page (with 10 lines), which is incorrect.

Relevant piece of code from my .js

function cria(){
$("#grid").jqGrid({
    datatype: 'json',
    url: 'json.jsp',
    jsonReader: {repeatitems: false},
    pager: '#paginado',
    rowNum: 10,
    rowList: [10,20,30],
    emptyrecords: "Não há registros.",
    recordtext: "Registros {0} - {1} de {2}",
    pgtext: "Página {0} de {1}",
    colNames:['Código','Descrição'],
    colModel:[
        {name:'codigo', width:80, sorttype:"int", sortable: true, editable: false},
        {name:'descricao', width:120, sortable: true, editable: true, editrules:{required:true}}
    ],
    viewrecords: true,
    editurl:"dadosGrid.jsp?edit=true",
    caption: "Grupos",
    hiddengrid: true
});             

$("#grid").jqGrid('navGrid','#paginado',{},
    {edit:true,url:"Adm?aux=edit",closeAfterEdit:true,reloadAfterSubmit:true},
    {add:true,url:"Adm?aux=add",closeAfterAdd:true,reloadAfterSubmit:true},             
    {del:false},
    {search:true},
    {refresh:true});    
};

Relevant piece of code from my .jsp

String json = "[";
for (UserAux user : users ){
    json += "{";
    json += "\"codigo\":\""+user.getCod()+"\",";
    json += "\"descricao\":\""+user.getDescricao()+"\",";
    json += "},";
}
json = json.substring(0,json.length()-1);   
json += "]";                        
out.println(json);  
%>
+4
source share
1 answer

The default options for jqGrid mean that you are doing server-side swapping . If you want to immediately return all the data from the server (which would be a good choice if you have 13 records), you should simply add an option loadonce: true.

, gridview: true, autoencode: true height: "auto" jqGrid. , edit:true, del:false, search:true refresh:true, navGrid, . , ( {} ).

+8

All Articles