How to change WebGrid action for getting data (.NET MVC3)

后端 未结 4 893
无人及你
无人及你 2021-02-10 00:28

I have a Partial View that renders WebGrid. My controller looks like

public ActionResult Index()
{
    return View();
}
public ActionResult GetUserList(int? pag         


        
4条回答
  •  隐瞒了意图╮
    2021-02-10 01:08

    After lot of monkeying around and digging (and even fiddling with Reflector with WebGrid's source code), I came to the conclusion that with WebGrid, you cannot control/change the Header link action.

    To create the header link URL, the path is taken from HttpContext.Request.Path, so there is no way to customize it to point to a different route.

    One very ugly hack would be to tap into to jQuery Ajax's events (since the header link uses jQuery.load to sort) and overwrite the URL:

    Album Id
    

    Better solution would be to use:

    • Telerik Grid which lets you specify custom routes and also offers much more flexibility in rendering your layout
    • or MvcContrib Grid (not sure if this lets you modify header links but definitely offers more flexibility than WebGrid)

提交回复
热议问题