我在 JqGrid 中对条目进行排序时遇到问题。Orderby 似乎不起作用。我在代码中设置了断点,我注意到 orderby 不会改变元素的顺序。知道有什么问题吗?
我将 LINQ to SQL 与 MySQL 一起使用(DbLinq 项目)。
我的操作代码:
public ActionResult All(string sidx, string sord, int page, int rows)
{
var tickets = ZTRepository.GetAllTickets().OrderBy(sidx + " " + sord).ToList();
var rowdata = (
from ticket in tickets
select new {
i = ticket.ID,
cell = new String[] {
ticket.ID.ToString(), ticket.Hardware, ticket.Issue, ticket.IssueDetails, ticket.RequestedBy, ticket.AssignedTo, ticket.Priority.ToString(), ticket.State
}
}).ToArray();
var jsonData = new
{
total = 1, // we'll implement later
page = page,
records = tickets.Count(),
rows = rowdata
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}