MvcContrib 寻呼机样式

发布于 2024-09-15 23:00:43 字数 56 浏览 10 评论 0原文

是否可以将 MvcContrib Grid 分页器设置为仅显示“1 2 3 4 ...”进行分页?

Is it possible to style the MvcContrib Grid pager to just show "1 2 3 4 ..." for paging?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原来分手还会想你 2024-09-22 23:00:44

据我所知,这个选项并不是现成的。我在 codeplex 上问了同样的问题,但似乎还没有准备好:

http://mvccontrib.codeplex。 com/workitem/5745

As far as I can tell, that option doesn't exist out of the box. I asked the same question on the codeplex but it seems to be not ready yet:

http://mvccontrib.codeplex.com/workitem/5745

路弥 2024-09-22 23:00:44

这是我对此类功能的实现:

@using MvcContrib.UI.Pager
@model MvcContrib.Pagination.IPagination
@{
    string action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
    string controller = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString();
}
@functions
{
    public RouteValueDictionary GetRoute(int page)
    {
        var routeValues = new RouteValueDictionary();
        foreach (var key in Context.Request.QueryString.AllKeys.Where(key => key != null))
        {
            routeValues[key] = Context.Request.QueryString[key];
        }
        routeValues["page"] = page;

        return routeValues;
    }   
}
<div class="pagination">
    <center>
        <span class="paginationRight">
            @{
                int thisPage = Model.PageNumber;
                if (Model.HasPreviousPage)
                {
                    for (int i = (5 < Model.PageNumber ? 5 : Model.PageNumber); i >= 1; i--)
                    {
                        int page = thisPage - i;
                        if (page > 0)
                        {
                <text>
                @Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
                </text>
                        }
                    }
                }
                <text> | @Model.PageNumber | </text>
                if (Model.HasNextPage)
                {
                    for (int i = 1; i <= (5 < Model.TotalPages - Model.PageNumber ? 5 : Model.TotalPages - Model.PageNumber); i++)
                    {
                        int page = thisPage + i;
                        if (page > 0)
                        {
                <text>
                @Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
                </text>
                        }
                    }
                }

            }
        </span>
    </center>
</div>

它并不漂亮或什么,但它对我来说工作得很好,并且很容易根据您的需要进行修改。

There is my implementation of such feature:

@using MvcContrib.UI.Pager
@model MvcContrib.Pagination.IPagination
@{
    string action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
    string controller = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString();
}
@functions
{
    public RouteValueDictionary GetRoute(int page)
    {
        var routeValues = new RouteValueDictionary();
        foreach (var key in Context.Request.QueryString.AllKeys.Where(key => key != null))
        {
            routeValues[key] = Context.Request.QueryString[key];
        }
        routeValues["page"] = page;

        return routeValues;
    }   
}
<div class="pagination">
    <center>
        <span class="paginationRight">
            @{
                int thisPage = Model.PageNumber;
                if (Model.HasPreviousPage)
                {
                    for (int i = (5 < Model.PageNumber ? 5 : Model.PageNumber); i >= 1; i--)
                    {
                        int page = thisPage - i;
                        if (page > 0)
                        {
                <text>
                @Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
                </text>
                        }
                    }
                }
                <text> | @Model.PageNumber | </text>
                if (Model.HasNextPage)
                {
                    for (int i = 1; i <= (5 < Model.TotalPages - Model.PageNumber ? 5 : Model.TotalPages - Model.PageNumber); i++)
                    {
                        int page = thisPage + i;
                        if (page > 0)
                        {
                <text>
                @Html.ActionLink(page.ToString(), action, controller, GetRoute(page), null)
                </text>
                        }
                    }
                }

            }
        </span>
    </center>
</div>

It is not beautifull or anything, but it works quite fine for me, and is very simple to modify it to your needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文