示例#1
0
        internal PagerBuilder(HtmlHelper html, AjaxHelper ajax, string actionName, string controllerName,
                              int totalPageCount, int pageIndex, PagerOptions pagerOptions, string routeName, RouteValueDictionary routeValues,
                              AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
        {
            _msAjaxPaging = (ajax != null);
            if (String.IsNullOrEmpty(actionName))
            {
                if (ajax != null)
                {
                    actionName = (string)ajax.ViewContext.RouteData.Values["action"];
                }
                else
                {
                    actionName = (string)html.ViewContext.RouteData.Values["action"];
                }
            }
            if (String.IsNullOrEmpty(controllerName))
            {
                if (ajax != null)
                {
                    controllerName = (string)ajax.ViewContext.RouteData.Values["controller"];
                }
                else
                {
                    controllerName = (string)html.ViewContext.RouteData.Values["controller"];
                }
            }
            if (pagerOptions == null)
            {
                pagerOptions = new PagerOptions();
            }

            _html           = html;
            _ajax           = ajax;
            _actionName     = actionName;
            _controllerName = controllerName;
            if (pagerOptions.MaxPageIndex == 0 || pagerOptions.MaxPageIndex > totalPageCount)
            {
                _totalPageCount = totalPageCount;
            }
            else
            {
                _totalPageCount = pagerOptions.MaxPageIndex;
            }
            _pageIndex      = pageIndex;
            _pagerOptions   = pagerOptions;
            _routeName      = routeName;
            _routeValues    = routeValues;
            _ajaxOptions    = ajaxOptions;
            _htmlAttributes = htmlAttributes;

            // start page index
            _startPageIndex = pageIndex - (pagerOptions.NumericPagerItemCount / 2);
            if (_startPageIndex + pagerOptions.NumericPagerItemCount > _totalPageCount)
            {
                _startPageIndex = _totalPageCount + 1 - pagerOptions.NumericPagerItemCount;
            }
            if (_startPageIndex < 1)
            {
                _startPageIndex = 1;
            }

            // end page index
            _endPageIndex = _startPageIndex + _pagerOptions.NumericPagerItemCount - 1;
            if (_endPageIndex > _totalPageCount)
            {
                _endPageIndex = _totalPageCount;
            }
        }
示例#2
0
 //todo new -xing
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions, IDictionary <string, string> searchParameter)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, null));
     }
     return(Pager(helper, pagedList.TotalCount, pagedList.PageSize, pagedList.PageIndex, null, null, pagerOptions, null, null, null, searchParameter));
 }
示例#3
0
 //todo add parameter Dictionary<string, string>
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, null));
     }
     return(Pager(helper, pagedList.TotalCount, pagedList.PageSize, pagedList.PageIndex, null, null, pagerOptions, null, null, null));
 }
示例#4
0
 private static MvcHtmlString Pager(HtmlHelper helper, PagerOptions pagerOptions, IDictionary <string, object> htmlAttributes)
 {
     return(new PagerBuilder(helper, null, pagerOptions, htmlAttributes).RenderPager());
 }
示例#5
0
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions, string routeName,
                                   RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, htmlAttributes));
     }
     return(Pager(helper, pagedList.TotalCount, pagedList.PageSize, pagedList.PageIndex, null, null, pagerOptions, routeName, routeValues, htmlAttributes));
 }
示例#6
0
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions, object htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, new RouteValueDictionary(htmlAttributes)));
     }
     return(Pager(helper, pagedList.TotalCount, pagedList.PageSize, pagedList.PageIndex, null, null, pagerOptions, null, null, htmlAttributes));
 }