たとえば、「14 のうち 14 のうち 11」ではなく、すべてのレコードも表示されています。この記事をチュートリアルとして使用しました
http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part
public ActionResult GetCurrentErrorsAJAX(JQueryDataTableParamModel param)
{
List<StepInstanceError> allCompanies = new List<StepInstanceError>();
allCompanies = InstanceErrorExpert.GetAllErrors();
IEnumerable<StepInstanceError> filteredCompanies;
filteredCompanies = allCompanies;
var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
Func<StepInstanceError, string> orderingFunction = (c => sortColumnIndex == 1 ? c.FilePath :
sortColumnIndex == 2 ? c.Notes :
c.Notes);
var sortDirection = Request["sSortDir_0"]; // asc or desc
if (sortDirection == "asc")
filteredCompanies = filteredCompanies.OrderBy(item => orderingFunction);
else
filteredCompanies = filteredCompanies.OrderByDescending(item => orderingFunction);
var displayedCompanies = filteredCompanies;
var result = from c in displayedCompanies
select new[] { Convert.ToString(c.StepInstanceErrorID),
Convert.ToString(c.StepInstanceID),
Convert.ToString(c.ErrorRow),
Convert.ToString(c.Notes),
c.FilePath,
c.Notes,
Convert.ToString(c.DateCreated)
};
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = allCompanies.Count(),
iTotalDisplayRecords = filteredCompanies.Count(),
aaData = result
},
JsonRequestBehavior.AllowGet);
}
<script>
$(function () {
var RefreshErrorTable = function () {
var oTable = $('#myDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "Errors/GetCurrentErrorsAJAX",
"bProcessing": true,
"aoColumns": [
{ "sName": "StepInstanceID" },
{ "sName": "ErrorRow" },
{ "sName": "FilePath" },
{ "sName": "Notes" },
{ "sName": "DateCreated" }
]
});
}
RefreshErrorTable();
});