我有一个显示员工列表的数据表。当我的员工人数在 0-2000 范围内时它工作正常,但之后加载该页面时会出现严重的滞后时间。这真的不足为奇,因为它在页面加载时加载了大量数据。我到处找,我找不到一个很好的例子来说明如何进行服务器端处理。我在 git hub 上找到的项目在我的计算机上确实无法运行(我遇到了很多“缺少引用”的错误)。这是我现在正在工作的代码
雇员.cshtml
@model EmployeeList
@{
Layout = null;
ViewBag.Title = "employees";
}
<html>
<head>
<head/>
<body>
<table id="employees_gridView">
<thead>
<tr>
<th
Name
</th>
<th>
Username
</th>
<th>
Job Category
</th>
<th>
Hire Date
</th>
</tr>
</thead>
<tbody>
@if (Model.RowList != null)
{
foreach (var item in Model.RowList)
{
<tr>
<td >
@Html.DisplayFor(i => item.DisplayName)
</td>
<td >
@Html.DisplayFor(i => item.UserName)
</td>
<td>
@Html.DisplayFor(i => item.JobCategoryName)
</td>
<td>
@Html.DisplayFor(i => item.hireDate)
</td>
</tr>
}
}
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
数据表 jquery 看起来像这样
$(document).ready(function(){
$('#employees_gridView').dataTable({
"bDestroy":true,
"bSortClasses": false,
"bDeferRender": true,
// here is the default setting for number of results to show on a page
"iDisplayLength": 10,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting" :[],
// here are the column specific settings
"aoColumns": [
{"aTargets": [ 0,1 ]},
null,
{"sClass": "DataTableCenterColumn"},
{"sType":"date", "sClass": "DataTableCenterColumn"
}]
});
});
这是处理页面加载请求的控制器方法
public ActionResult Index()
{
EmployeeList employeeList = getEmployeeList();
return View("Index", employeeList );
}
有人可以告诉我如何将此客户端数据表更改为服务器端处理数据表。