我希望有一个jqGrid的类,它可以通过MVC返回JSON [英] i want a jqGrid class that can return json by mvc
本文介绍了我希望有一个jqGrid的类,它可以通过MVC返回JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MVC剃须刀使用的jqGrid
Using jqGrid in mvc razor
我想一个类,它可以去的jqGrid JSON格式并绑定网格。
I want a class that can go for jqGrid json format and bind the grid.
推荐答案
我觉得你不需要定义任何类生成的的需要jqGrid的相对=nofollow> JSON数据。你可以返回匿名对象:
I think that you don't need to define any class to produce JSON data needed for jqGrid. You can return anonymous object:
public JsonResult DynamicGridData (string sidx, string sord, int page, int rows)
{
var query = ...;
var totalRecords = query.Count();
return Json(new {
total = (totalRecords + rows - 1) / rows,
page,
records = totalRecords,
rows = (from item in query
select new {
id = item.Id.ToString(),
cell = new[] {
item.FirstName,
item.LastName,
item.Votes.ToString(),
item.Title
}
}).ToList()
},
JsonRequestBehavior.AllowGet);
}
这篇关于我希望有一个jqGrid的类,它可以通过MVC返回JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文