【发布时间】:2017-08-23 13:25:57
【问题描述】:
我在使用 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
}
我不太确定从这里去哪里。有什么建议吗?
【问题讨论】:
-
嘿,伙计,您如何在 Razor 页面中使用 BootgridRequestData 模型。您是否介意在某个我无法获得我认为可以实际工作的地方举一个例子。寻求一点指导
标签: c# asp.net asp.net-mvc linq jquery-bootgrid