0
正如你在下面看到的,我有3张图片。 (5, 10 and 20 data per page)
。我不知道为什么在10 and 20 per page
数据丢失,如图片提供。在jqGrid中缺少显示数据
代码
public JsonResult GetDPS(string sidx, string sord, int page, int rows, string startdate, string enddate, string EmployeeId, string month, string year, int ClassificationId)
{
var context = new Entities();
var _pr = new Repository();
int _month = Convert.ToInt32(month);
int _employeeid = Convert.ToInt32(EmployeeId);
int _year = Convert.ToInt32(year);
if (_month > 0 && _year > 0)
{
DateTime Dstartdate = new DateTime(_year, _month, 1);
startdate = Dstartdate.AddDays(-1).ToShortDateString();
enddate = Dstartdate.AddMonths(1).ToShortDateString();
}
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
var periods = _pr.GetDPSList(Convert.ToDateTime(startdate), Convert.ToDateTime(enddate), _employeeid, ClassificationId);
int totalRecords = periods.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords/(float)pageSize);
var reqs = periods.OrderBy("it." + sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize);
int i = 0;
var rowsObj = new object[pageSize > totalRecords ? totalRecords : pageSize];
foreach (vwDPSPerEmployee req in reqs)
{
int rowId = i;
int DPSHeaderId = Convert.ToInt32(req.DPSHeaderId);
string DateApplied = req.DateApplied.Value.ToShortDateString();
string DPSClassification = req.DPSClassificationDesc;
string StartDate = req.DateFrom.Value.ToShortDateString();
string EndDate = req.DateTo.Value.ToShortDateString();
string Departure = req.Departure.Value.ToShortTimeString();
string Arrival = req.Arrival.Value.ToShortTimeString();
string Destination = req.Destination;
string ContactPerson = req.ContactPerson;
string Purpose = req.Purpose;
rowsObj[i] = new { id = i, cell = new object[] { rowId, DPSHeaderId, DateApplied, DPSClassification, StartDate, EndDate, DateofDPS, Departure, Arrival, Destination, ContactPerson, Purpose } };
i++;
}
if (totalRecords != 0)
{
for (int j = 0; j < rowsObj.Length; j++)
{
if (rowsObj[j] == null)
{ rowsObj[j] = new { id = j, cell = new object[] { j, j, "", "" } }; }
else { }
}
}
var result = new JsonResult();
result.Data = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = rowsObj
};
return result;
}
有谁遇到这样?或者有人知道吗?我花了几天时间来解决这个问题。
请写始终其中** **版本的jqGrid的使用并从中** **叉的jqGrid的(免费的jqGrid,商业Guriddo jqGrid的JS或旧的jqGrid版本<= 4.7)。 jqGrid是用JavaScript编写的jQuery插件。您应该发布您使用的JavaScript代码。此外,如果您怀疑jqGrid工作不正常,则应准备演示,以演示问题。您可以使用Chrome/IE的开发工具或[Fiddler](http://www.telerik.com/fiddler)等工具来获取服务器返回的JSON数据。之后,可以创建演示,该演示使用数据而不使用服务器。 – Oleg