easyui datagrid 逻辑分页

function getGroupUsers(groupPath) {
$('#tbGroupUsersList').datagrid({

width: 800,
height: 100,
nowrap: false,
striped: true,
fit: true,
url: '/AD/getGroupObject',

queryParams: {
GroupPath: groupPath
},
frozen: true,
frozenColumns:[[
{ field: 'ck', checkbox: true },
{ field: 'ObjectType', title: '类型', width: 50, align: 'center' },
{ field: 'UserName', title: '姓名', width: 100, align: 'center' },
{
field: 'ADAccount', title: 'AD域帐号', width: 100, align: 'center'
},
]] ,
columns: [[

{
field: 'EmployeeID', title: '工号', width: 70, align: 'center'
},

{
field: 'Department', title: '部门名称', width: 100, align: 'left'
},
{
field: 'DeptLevel', title: '部门级别', width: 70, align: 'center'
},
{
field: 'Postion', title: '岗位', width: 80, align: 'center'
},
{ field: 'Telephone', title: '联系电话', width: 150, align: 'left', hidden: 'true' },

{
field: 'JobLevel', title: '职级', width: 50, align: 'center'
},

{
field: 'ADStatus', title: 'AD状态', width: 50, align: 'center'
},

{
field: 'HrStatus', title: 'HR状态', width: 50, align: 'center'
},

{
field: 'Groups', title: '所在组', width: 90, align: 'left'
}
]],

toolbar: [
{
id: 'btnDel',
text: '删除',
iconCls: 'icon-delete',
handler: function () {
//编辑处理
var row = $('#tbGroupUsersList').datagrid('getSelections');
if (row != null) {
var vGrouplist = "";
for (var i = 0; i < row.length; i++) {

vGrouplist += row[i].ADAccount + ",";
}
if (vGrouplist != "") {
$.messager.confirm('确认', '确认要从组' + groupPath.split(',')[0] + '中删除' + vGrouplist + "吗?", function (r) {
if (r) {
DelObjectFromGroup(vGrouplist, groupPath);
}
});
}
else {
$.messager.alert('警告', '请至少选择一项删除!', 'warning');
}
}
else {
$.messager.alert('警告', '请至少选择一项删除!', 'warning');
}
}
}, {
id: 'btnExcel',
text: '导出Excel',
iconCls: 'icon-excel',
handler: function () {
location.href = '/AD/DownLoadCSVFile?GroupPath=' + groupPath;
}
}
],
pagePosition: 'both',
pageNumber: 1,
pagination: true,//分页控件
rownumbers: true,//显示行号
pageSize: 10,
pageList: [10, 15, 50, 100],
loader: myLoader
});

}

function myLoader(param, success, error) {
var that = $(this);
var opts = that.datagrid("options");
if (!opts.url) {
return false;
}
var cache = that.data().datagrid.cache;
if (!cache) {
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: "json",
success: function (data) {
that.data().datagrid['cache'] = data;
success(bulidData(data));
},
error: function () {
error.apply(this, arguments);
}
});
} else {
success(bulidData(cache));
}
function bulidData(data) {
debugger;
var temp = $.extend({}, data);
var tempRows = [];
var start = (param.page - 1) * parseInt(param.rows);
var end = start + parseInt(param.rows);
var rows = data.rows;
for (var i = start; i < end; i++) {
if (rows[i]) {
tempRows.push(rows[i]);
} else {
break;
}
}
temp.rows = tempRows;
return temp;
}
}

上一篇:php中的implements 使用详解


下一篇:Redis系列-好玩的用法