我在使用 ASP.Net MVC 实现 jQuery 引导网格时遇到了一些问题。我无法实现排序、搜索、分页等功能。
这就是我的控制器中的内容:
public JsonResult IndexJson(BootgridRequestData model)
{
var contacts = (from x in db.ContactSet
select new
{
x.AccountId,
x.FirstName,
x.LastName,
x.FullName,
x.JobTitle,
x.ParentCustomerId,
x.EMailAddress1,
x.Telephone1,
x.MobilePhone,
x.Fax,
x.GenderCode,
x.BirthDate
}).ToList();
// This tResult throws a Non-invocable member cannot be used like a method error.
var tResult = BootgridResponseData<JsonResult>() {
current = model.current,
rowCount = model.rowCount,
rows = contacts,
total = contacts.Count
};
return Json(tResult, JsonRequestBehavior.AllowGet);
}
然后我有以下帮助类:
public class BootgridRequestData
{
public int current { get; set; }
public string rowCount { get; set; }
public string searchPhrase { get; set; }
public IEnumerable<SortData> sortItems { get; set; }
}
public class BootgridResponseData<T> where T : class
{
public int current { get; set; } //? current page
public int rowCount { get; set; } //? rows per page
public IEnumerable<T> rows { get; set; } //? items
public int total { get; set; } //? total rows for whole query
}
public class SortData
{
public string Field { get; set; } //? Field Name
public string Type { get; set; } //? ASC or DESC
}
我不太确定从这里去哪里。有什么建议吗?