c# - Sorting mechanism not getting applied when a partial view is rendered in a view using @Ajax.ActionLink -


i working on mvc 4 project. i've done provided ajax action link on view.

@ajax.actionlink("display resources", "resources", "resources", null, new ajaxoptions { httpmethod = "get", insertionmode = insertionmode.replace, updatetargetid = "showallresources"}); 

and on action link i've rendered 1 partial view display table database.

showallresources div in display partial view.

in partial view i've provided 3 different ajax action links sort data.

<th>             @ajax.actionlink("first name", "resources", new { sortorder = viewbag.firstnamesort }, new ajaxoptions { httpmethod="get"})         </th>          <th>             @ajax.actionlink("last name", "resources", new { sortorder = viewbag.lastnamesort }, new ajaxoptions { httpmethod = "get" })         </th>         <th>             @ajax.actionlink("release date", "resources", new { sortorder = viewbag.releaseddatesrot }, new ajaxoptions { httpmethod = "get" })         </th> 

and code in controller action method

 [outputcache(nostore=true,duration=0,varybyparam="*")]  public actionresult resources(string sortorder)         {              viewbag.firstnamesort = string.isnullorempty(sortorder)?"name_desc":"";             viewbag.lastnamesort = string.isnullorempty(sortorder) ? "lname_desc" : "";             viewbag.releaseddatesrot = sortorder == "date" ? "date_desc" : "date";              if(request.isajaxrequest())             {                 var tbluser = s in rostermanagementcontext.tblusers                               select s;                 switch (sortorder)                 {                     case "name_desc":                         tbluser = tbluser.orderbydescending(a => a.firstname);                         break;                     case "lname_desc":                         tbluser = tbluser.orderbydescending(a => a.lastname);                         break;                     case "date_desc":                         tbluser = tbluser.orderbydescending(a => a.releasedate);                         break;                     default:                         tbluser = tbluser.orderby(a => a.firstname);                         break;                  }                   return partialview("_displayresources", tbluser.tolist());             }              lookuptbluserlistviewmodel wrapperviewmodel = helpers.configurewrapperviewmodel();             return view(wrapperviewmodel);         } 

what happens when user clicks on display resources link switch case goes default , sorts list depending on firstname column.

but when user clicks on other link such releasedate or lastname sort data on column, not display data in sorted format shows me sorted data depending on column in debugger.

i have followed this link learn sorting paging , filtering in mvc

what i'm missing out?

please help..

thank you.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -