I've got problem with sorting entries in JqGrid. Orderby seem to not work. I set breakpoint in code and I noticed, that orderby doesn't change order of elements. Any idea what could be wrong?
I'm using LINQ to SQL with MySQL (DbLinq project).
My action code:
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);
}
Try with the following
Here I suppose that the type of your ticket object is
Ticket
.The
tickets
variable is ordered, but then you use that as the source for another query which is NOT ordered so it's order is undetermined. You want the orderby on the second LINQ query.