示例#1
0
 public static MvcHtmlString AjaxPagerForMode <T>(this HtmlHelper html, PagedList <T> pagedList, string actionName, string controllerName,
                                                  string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes, PaginationMode mode = PaginationMode.NextPreviousFirstLast, ShowInfoGoMode gom = ShowInfoGoMode.Default, PageIndexBoxType pageIndexBoxType = PageIndexBoxType.TextBox, string pageNumberFormatString = "")
 {
     if (pagedList == null)
     {
         return(Pager(html, null, htmlAttributes));
     }
     return(AjaxPagerForMode(html, pagedList.TotalPageCount, pagedList.CurrentPageIndex, actionName, controllerName, routeName, routeValues, ajaxOptions, htmlAttributes, mode, gom, pageIndexBoxType, pageNumberFormatString));
 }
示例#2
0
        public static MvcHtmlString AjaxPagerForMode(this HtmlHelper html, int totalPageCount, int pageIndex, string actionName, string controllerName,
                                                     string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes, PaginationMode mode = PaginationMode.NextPreviousFirstLast, ShowInfoGoMode gom = ShowInfoGoMode.Default, PageIndexBoxType pageIndexBoxType = PageIndexBoxType.TextBox, string pageNumberFormatString = "")
        {
            PagerOptions pageOpt = new PagerOptions()
            {
                //PageIndexParameterName = "pageIndex",
                AutoHide = true,
                /*跳转区*/
                ShowPageIndexBox = true,             /*是否显示跳转*/
                PageIndexBoxType = pageIndexBoxType, /*跳转输入方式*/
                ShowGoButton     = true,
                ShowInfo         = true,
                PageIndexBoxWrapperFormatString = "到第{0}页",
                CssClass = "pager",

                /*FirstPageText = "第一页",
                 * PrevPageText = "前一页",
                 * NextPageText = "下一页",
                 * LastPageText = "最后页",
                 * PagerItemWrapperCss = "page-default",*/
                AlwaysShowFirstLastPageNumber = true,
                PrevItemWrapperCss            = "page-pre",
                NextItemWrapperCss            = "page-next",
                LastItemWrapperCss            = "page-last",
                FirstItemWrapperCss           = "page-fir",

                /*数字部分
                 * NumericPagerItemWrapperCss = "page-break",*/
                ShowNumericPagerItems      = true,
                PageNumberFormatString     = pageNumberFormatString,
                PageNumberCss              = "page-num",
                SeparatorHtml              = " ",
                CurrentPagerItemWrapperCss = "page-cur",
                DisabledCss                        = "page-disabled",
                MorePagerItemWrapperCss            = "<span>{0}</span>",
                GoToPageSectionWrapperFormatString = ""
            };

            if (mode == PaginationMode.NextPrevious)
            {
                pageOpt.AlwaysShowFirstLastPageNumber = false;
                pageOpt.ShowPageIndexBox      = false;
                pageOpt.ShowNumericPagerItems = false;
                pageOpt.ShowFirstLast         = false;
                pageOpt.ShowMorePagerItems    = false;
                pageOpt.TotalInfoFormatString = "共%_TotalPage_%页 当前第%_PageIndex_%页";
            }
            if (mode == PaginationMode.NextPreviousFirstLast)
            {
                pageOpt.ShowPageIndexBox      = false;
                pageOpt.ShowNumericPagerItems = false;
            }
            if (mode == PaginationMode.Numerics)
            {
                pageOpt.AlwaysShowFirstLastPageNumber = false;
                pageOpt.ShowFirstLast = false;
            }
            if (gom == ShowInfoGoMode.Simple)
            {
                pageOpt.PageIndexBoxWrapperFormatString = "";
                pageOpt.TotalInfoFormatString           = "%_PageIndex_%/%_TotalPage_%";
            }
            if (gom == ShowInfoGoMode.OnlyShowInfo)
            {
                pageOpt.ShowPageIndexBox = false;
            }
            if (gom == ShowInfoGoMode.OnlyInfoSimple)
            {
                pageOpt.ShowPageIndexBox      = false;
                pageOpt.TotalInfoFormatString = "%_PageIndex_%/%_TotalPage_%";
            }

            if (gom == ShowInfoGoMode.None)
            {
                pageOpt.ShowPageIndexBox = false;
                pageOpt.ShowInfo         = false;
            }
            return(AjaxPager(html, totalPageCount, pageIndex, actionName, controllerName, routeName, pageOpt, routeValues, ajaxOptions, htmlAttributes));
        }