MVC WebGrid自定义URL用于排序&分页

时间:2015-03-27 11:10:46

标签: c# asp.net-mvc-4 model-view-controller html-helper webgrid

我一直试图找到一种方法来覆盖为排序而生成的网址。分页。因为我需要在它生成的URL中放置一个会话ID。我尝试过自定义格式。但那没用。它有一个更简单的方法吗?

@{
var grid = new WebGrid(canPage: true, canSort: true, ajaxUpdateContainerId: "grid", rowsPerPage: @Model.Paging.PageSize, defaultSort: "Test");
grid.Bind(Model.TestUnit, rowCount: Model.Paging.TotalRecordCount, autoSortAndPage: false, );
grid.Pager(WebGridPagerModes.FirstLast, firstText: "First", lastText: "Last");
@grid.GetHtml(htmlAttributes: new { id = "grid" }, tableStyle: "table table-striped table-hover",
    columns: grid.Columns(
    grid.Column("", format: @<img class="thumb" src="#" height="35" width="35" alt="" />),
    grid.Column("Test", header: "Test"),
    grid.Column("Test2", header: "Test2"),
    grid.Column("", format: @<text>@Html.ActionLink("Details", "Details", new { id = item.test}) </text>, canSort: false)
                            ));
}

0 个答案:

没有答案