大全百家
自定义设置每页数量
**
jsp 分页 10,20,30,40条显示,想做为10,20,50,100,500,1000 的实现方式
最终效果如下图:
代码如下:
// var pageSize = 10 ;
var pageNumber = 1;
$(function(){
$('#invoice').datagrid({
url : '${ctx}/List',
method : 'post',
nowrap: false,
striped: true,
collapsible:false,
queryParams:{status:'0'},
fitColumns: false,
pagination:true,
rownumbers:true,
remoteSort: false,
pageNumber:pageNumber,
singleSelect:false,
// pageSize:pageSize,
pageSize: 20,//每页显示的记录条数,默认为10
pageList: [10,20,50,100,500],
width:"100%",
height:"100%",
columns :
结束
使用ajax 异步请求后,获取数据进行分页
$(’#Invoice’).datagrid(‘loadData’,data)
function queryPaymentData(fractnAcntname,id){
$.ajax({
type: "POST",
cache:false,
async : false,
url: "${ctx}/ss/List",
data: {
id : id
},
dataType: "json",
beforeSend: function(XHR){
$.messager.progress({
text : '执行中,请稍后......'
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$.messager.progress('close');
layer.alert("服务端出错,请稍候尝试或联系系统维护人员!");
},
success: function(data){
$.messager.progress('close');
if(data.total>0){
$('#Invoice').datagrid('loadData',data);// 导入数据,分页显示 不要加上 row --data.row
$('#select').datagrid('loadData', { total: 0, rows: [] });
}else{
$('#Invoice').datagrid('loadData', { total: 0, rows: [] });//清空列表数据
$('#select').datagrid('loadData', { total: 0, rows: [] });
}
}