1、datagrid属性pagination设为true
2、loadFilter中加入分页相关代码
优点:可以减少界面中<tr>容量,加快加载页面的速度
$('#employeeDG').datagrid({
title:'职员列表',
fit: true,
fitColumns: false,
border: false,
//view: scrollview,
pagination:true,
pageSize:50,
columns : [ [
{field: 'deptName',title:'部门',width:160},
{field : 'name',title : '姓名',width : 100},
{field:'extentionPhone',title:'分机号',width:100},
{field:'groupPhone',title:'深南短号',width:100},
{field:'corporatePhone',title:'公务手机',width:120,
formatter: function(value, row, index){
if (row.employeeLevel <= 2 ) {
return null;
} else {
return value;
}
}
},
{field:'mobile',title:'手机号码',width:120, hidden:true}
] ],
loadFilter : function(data) {
var result = {};
if (!data.hasOwnProperty("success")) {
result = data;
} else {
if (data.success == true) {
result = data.obj;
} else {
$.messager.show({
msg : data.msg,
title : '提示'
});
return {'total' : 0, 'rows' : []};
}
}
var dg = $(this);
var opts = dg.datagrid('options');
var pager = dg.datagrid('getPager');
pager.pagination({
onSelectPage:function(pageNum, pageSize){
opts.pageNumber = pageNum;
opts.pageSize = pageSize;
pager.pagination('refresh', {
pageNumber:pageNum,
pageSize:pageSize
dg.datagrid('loadData', result);
});
if (!result.originalRows){
if (result.rows.length == allProcessData.length) {
result.originalRows = allProcessData;
result.originalRows = (result.rows);
var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
var end = start + parseInt(opts.pageSize);
result.rows = (result.originalRows.slice(start, end));
if (!result.footer) {
var footer = [{departmentCode: result.total, partQtyBacklog: 0, panelQtyBacklog: 0, partsArea: 0, startQuantity: 0}];
$.each(result.originalRows, function(index, value) {
footer[0].partQtyBacklog += value.partQtyBacklog;
footer[0].panelQtyBacklog += value.panelQtyBacklog;
footer[0].partsArea += value.partsArea;
footer[0].startQuantity += value.startQuantity;
});
result.footer = footer;
return result;
}