코드를 볼 수없는 것은 조금 어렵다. 그러나 여기에 내가있는 jqGrid를 사용하는 프로젝트에 페이지 매김을 구현하기 위해 내 프로젝트 중 하나에 사용 된 코드는
서버 측 코드 (어쨌든 당신을 할 수 있는지, 또는 디버깅을 시작하는 위치에 표시)입니다
public ActionResult GridData(int page, int rows, string searchField = "", string searchString = "",
string searchOper = "", string sidx = "ID", string sord = "desc")
{
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
var items = _repo.GetItemDatacollection(searchField, searchString, searchOper, pageIndex, pageSize, sidx, sord);
int totalRecords = _repo.GetAll().Count();
var totalPages = (int)Math.Ceiling(totalRecords/(float)pageSize);
var jsonData = new
{
total = totalPages,
page,
records = totalRecords,
rows = (from item in items.ToList()
select new
{
i = item.ID,
cell = new[] { item.ID, item.Name }
}).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
기본적으로 GetItemDataCollection은 이와 유사합니다.
return _entities.Set<T>().Where(ConvertOpr(searchOper, searchField), searchString)
.OrderBy(sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSize);
있는 jqGrid 구현
jQuery('#theGrid').jqGrid({
url: '@Url.Action("GridData")',
datatype: 'json',
mtype: 'GET',
//...
});
참조 Olegs의 anwser (내가 LINQ를 사용하여있는 jqGrid에서 검색을 구현하기위한 매우 유용하지 않을 경우 중추적이었다, 그 안에 스콧 오클라호마의 동적 LINQ 라이브러리를 사용했다) 여기에 : http://stackoverflow.com/questions/8479777/add-paging-for-jqgrid –