1.在操作的model中:
2.在控制器中:
var aIndividuals = new PagedList<实体>(集合数据, command.Page - , command.PageSize);//将从数据库获取到的集合进行分页 var gridModel = new DataSourceResult
{
Data = aIndividuals.Select(x =>
{
var m = x.ToModel();
m.Id = x.Id; if (x.CreateTime == null)
{
m.CreateTimeStr = "";
}
else
{
m.CreateTimeStr = x.CreateTime.Value.ToString("yyyy-MM-dd");//创建时间
}
if (x.CheckedTime == null)
{
m.CheckedTimeStr = "";
}
else
{
m.CheckedTimeStr = x.CheckedTime.Value.ToString("yyyy-MM-dd");
} return m;
}),
Total = aIndividuals.TotalCount
};
return Json(gridModel);