public Hashtable GetDepartmentEmployees(string departmentId, int index, int size)
{
string sql = "select * from t_employee where dept_id = '" + departmentId + "'";
ArrayList dataAll = DBUtil.Select(sql);
//实现一个内存分页(实际应该使用SQL分页)
ArrayList data = new ArrayList();
int start = index * size, end = start + size;
for (int i = 0, l = dataAll.Count; i < l; i++)
{
Hashtable record = (Hashtable)dataAll[i];
if (record == null) continue;
if (start <= i && i < end)
{
data.Add(record);
}
}
Hashtable result = new Hashtable();
result["data"] = data;
result["total"] = dataAll.Count;
// 分页填充细节处理
function fillData(pageIndex, pageSize, dataResult, grid) {
var data = dataResult.data, totalCount = dataResult.total;
var arr = [];
var start = pageIndex * pageSize, end = start + pageSize;
for (var i = start, l = end; i < l; i++) {
var record = data[i];
if (!record) continue;
arr.push(record);
}