正如你在这张图片中看到的
我的数据库上有 13 条记录,但寻呼机说它只有 1 页(有 10 行),这是不正确的。
来自我的 .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});
};
来自我的 .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);
%>
最佳答案
jqGrid 的默认选项意味着你实现了 服务器端分页 .如果您想一次从服务器返回所有数据(如果您有 13 条记录,这将是一个不错的选择),您只需添加 loadonce: true
选项。
此外,我建议您添加 gridview: true
, autoencode: true
和 height: "auto"
jqGrid 的选项。此外,您应该删除 edit:true
, del:false
, search:true
和 refresh:true
您在选项中使用的选项 navGrid
因为你在错误的地方使用那里。如果你想指定选项,你应该指定第二个参数的属性(在你的代码中是 {}
)。
关于json - jqGrid - 分页无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20267596/