Java中jqGrid jQuery的外部分页
我开发了如下代码Java中jqGrid jQuery的外部分页,java,javascript,jquery,ajax,jqgrid,Java,Javascript,Jquery,Ajax,Jqgrid,我开发了如下代码 jQuery(document).ready(function(){ jQuery("#records").jqGrid({ height:350, datatype: 'local', colNames:['Policy Name','Policy Type', 'Time allowed (HH:mm)','Expiration Duration (days)','Session Pulse(minutes)','De
jQuery(document).ready(function(){
jQuery("#records").jqGrid({
height:350,
datatype: 'local',
colNames:['Policy Name','Policy Type', 'Time allowed (HH:mm)','Expiration Duration (days)','Session Pulse(minutes)','Description'],
colModel :[
{name:'pName', index:'pName', editable:true,sorttype:'text',width:150,editoptions:{size:10},formatter:'showlink',formatoptions:{baseLinkUrl:'javascript:' , showAction: "GetAndShowUserData(jQuery('#list2'),'",addParam: "');"}},
{name:'pType', index:'pType', sorttype:'text',editable:true,width:150,editoptions:{size:10}},
{name:'timeAllowed', index:'timeAllowed', sorttype:'text',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'expDuration', index:'expDuration', sorttype:'text',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'sessionPulse', index:'sessionPulse',sorttype:'int',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'description', index:'description', sortable:false,editable:true,width:200,editoptions:{size:10}}],
pager:jQuery('#pager'),
rowNum:10,
sortname: 'pName',
autowidth:true,
altRows:true,
drag:true,
sortorder: "asc",
rowList:[2,5,10,20],
viewrecords: true,
loadonce:false,
multiselect: true,
/*
onSelectRow: function(id){
var gr = jQuery("#records").jqGrid('getGridParam','selrow');
if( gr != null ) jQuery("#records").jqGrid('editGridRow',gr,{height:280,reloadAfterSubmit:false});
else alert("Please Select Row");
},
editurl: "server.php",
*/
caption:'Manage Policy'
});
});
现在,我想在用户按下>>按钮时向servlet发出一个Ajax请求,以获取下一条记录。我在网上搜索了很多,但是我发现了很多PHP代码,但是我不能理解PHP;我想用Java开发这个东西。我该怎么做呢?正如GPS所说,jqGrid中的分页是通过对当前数据集进行分页来实现的。您必须加载一大组数据,它将遍历该数据集。也许有办法让它按照你想要的方式表现,但我不知道怎么做 对于我的网格,我使用触发Ajax调用来获取下一页数据。当数据返回时,我只是清除网格(clearGridData)并使用addRowData添加新的数据集 我是一名程序员,所以我不知道如何用Java进行数据库调用,但这不是一个真正的jqGrid问题
要确定有多少页,您需要计算要分页的所有记录的数量,并将其除以每页网格上显示的记录数。jQgrid自动管理这件事。您只需要传递完整的条目列表,它将在第一页上显示一些条目(如其配置中所述),在另一页上显示其余条目,等等……但我想管理外部分页,例如,如果用户按“下一步”,它将调用服务器,并从ajax调用中获取下一条记录。