jquery - asp.net mvc with jqgrid and orderby -


i'm stuck on orderby. code in example:

    public actionresult dynamicgriddata(string sidx, string sord, int page, int rows)     {         var repository = new itemrepository();         int pageindex = convert.toint32(page) - 1;         int pagesize = rows;         int totalrecords = repository.getitemquery().count();         var totalpages = (int) math.ceiling(totalrecords/(float) pagesize);          iqueryable<item> items = repository.getitemquery()             .orderby(sidx + " " + sord) // <-- problem here.             .skip(pageindex*pagesize)             .take(pagesize);          var jsondata = new                         {                             total = totalpages,                             page,                             records = totalrecords,                             rows = (from item in items                                     select new                                             {                                                 = item.id,                                                 cell = new[]                                                         {                                                             item.id.tostring(), item.description                                                         }                                             }).toarray()                         };         return json(jsondata, jsonrequestbehavior.allowget);     } 

in code, model looks this:

public class person{     public int personid {get; set;}     public string name {get; set;} } 

how set in orderby method?

ps. in code, see 2 calls. count , getting paged stuff. 2 database calls or one?

you use dynamic linq.

the orderby method expects expression , not string trying pass. may take @ following blog post illustrates orderby extension method method can take string parameter.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -