Exemple #1
0
 public static MvcHtmlString Pager <T>(this HtmlHelper helper, PagedList <T> pagedList, PagerOptions pagerOptions, string routeName, object routeValues)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, null));
     }
     return(Pager(helper, pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, pagerOptions, routeName, routeValues, null));
 }
Exemple #2
0
        //Ajax pager builder
        internal PagerBuilder(AjaxHelper ajaxHelper, int totalPageCount, int pageIndex, PagerOptions pagerOptions,
                              MvcAjaxOptions ajaxOptions)
        {
            _ajaxPagingEnabled = true;
            if (ajaxHelper == null)
            {
                throw new ArgumentNullException("ajaxHelper");
            }
            if (pagerOptions == null)
            {
                pagerOptions = new PagerOptions();
            }
            _ajax = ajaxHelper;
            if (pagerOptions.MaximumPageNumber == 0 || pagerOptions.MaximumPageNumber > totalPageCount)
            {
                _totalPageCount = totalPageCount;
            }
            else
            {
                _totalPageCount = pagerOptions.MaximumPageNumber;
            }
            _pageIndex    = pageIndex;
            _pagerOptions = pagerOptions;
            _ajaxOptions  = ajaxOptions ?? new MvcAjaxOptions();

            // 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;
            }
        }
Exemple #3
0
 private static MvcHtmlString Pager(HtmlHelper helper, PagerOptions pagerOptions, IDictionary <string, object> htmlAttributes)
 {
     return(new PagerBuilder(helper, null, pagerOptions, htmlAttributes).RenderPager());
 }
Exemple #4
0
 public static MvcHtmlString Pager <T>(this HtmlHelper helper, PagedList <T> pagedList, PagerOptions pagerOptions, IDictionary <string, object> htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, htmlAttributes));
     }
     return(Pager(helper, pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, pagerOptions, null, null, htmlAttributes));
 }
Exemple #5
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/AjaxPager/Constructor[@name="AjaxPager2"]/*'/>
 public AjaxPager(AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
     : this(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions, ajaxOptions)
 {
 }
Exemple #6
0
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(ajax, pagerOptions, htmlAttributes));
     }
     return(Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions, htmlAttributes));
 }
Exemple #7
0
 public static MvcHtmlString AjaxPager <T>(this HtmlHelper html, PagedList <T> pagedList, string routeName, object routeValues, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         return(AjaxPager(html, pagerOptions, null));
     }
     return(AjaxPager(html, pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, routeName, pagerOptions, routeValues, ajaxOptions,
                      null));
 }
Exemple #8
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/HtmlPager/Constructor[@name="HtmlPager3"]/*'/>
 public HtmlPager(HtmlHelper html, IPagedList pagedList, PagerOptions pagerOptions) : this(html, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions)
 {
 }
Exemple #9
0
 //jQuery Ajax pager builder
 internal PagerBuilder(HtmlHelper helper, string actionName, string controllerName, int totalPageCount,
                       int pageIndex, PagerOptions pagerOptions, string routeName, RouteValueDictionary routeValues,
                       AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes) : this(helper, null, actionName,
                                                                                                    controllerName, totalPageCount, pageIndex, pagerOptions, routeName, routeValues, ajaxOptions, htmlAttributes)
 {
 }
Exemple #10
0
 public static MvcHtmlString AjaxPager <T>(this HtmlHelper html, PagedList <T> pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions, object htmlAttributes)
 {
     if (pagedList == null)
     {
         return(AjaxPager(html, pagerOptions, new RouteValueDictionary(htmlAttributes)));
     }
     return(AjaxPager(html, pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null,
                      ajaxOptions, htmlAttributes));
 }
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerOptionsBuilder/Constrctor[@name="PagerOptionsBuilder"]/*'/>
 public PagerOptionsBuilder(PagerOptions pagerOptions)
 {
     _pagerOptions = pagerOptions;
 }
Exemple #12
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.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, pagerOptions, null, null, htmlAttributes));
 }
Exemple #13
0
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions)
 {
     if (pagedList == null)
     {
         return(Pager(helper, pagerOptions, null));
     }
     return(Pager(helper, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, pagerOptions, null, null, null));
 }
Exemple #14
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;
            }
        }
Exemple #15
0
 private static MvcHtmlString Pager(AjaxHelper ajax, PagerOptions pagerOptions, IDictionary <string, object> htmlAttributes)
 {
     return(new PagerBuilder(null, ajax, pagerOptions, htmlAttributes).RenderPager());
 }
Exemple #16
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/HtmlPager/Constructor[@name="HtmlPager1"]/*'/>
 public HtmlPager(HtmlHelper html, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions)
 {
     _htmlHelper       = html;
     _totalItemCount   = totalItemCount;
     _pageSize         = pageSize;
     _currentPageIndex = pageIndex;
     _pagerOptions     = pagerOptions;
 }
Exemple #17
0
 public static MvcHtmlString Pager <T>(this AjaxHelper ajax, PagedList <T> pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
 {
     return(pagedList == null?Pager(ajax, pagerOptions, null) : Pager(ajax, pagedList.TotalPageCount, pagedList.CurrentPageIndex,
                                                                      null, null, null, pagerOptions, null, ajaxOptions, null));
 }
Exemple #18
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/AjaxPager/Constructor[@name="AjaxPager1"]/*'/>
 public AjaxPager(AjaxHelper ajax, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     _ajaxHelper       = ajax;
     _totalItemCount   = totalItemCount;
     _pageSize         = pageSize;
     _currentPageIndex = pageIndex;
     _pagerOptions     = pagerOptions;
     _ajaxOptions      = ajaxOptions;
 }
Exemple #19
0
 public static MvcHtmlString Pager <T>(this AjaxHelper ajax, PagedList <T> pagedList, string routeName, object routeValues, PagerOptions pagerOptions,
                                       AjaxOptions ajaxOptions, object htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(ajax, pagerOptions, new RouteValueDictionary(htmlAttributes)));
     }
     return(Pager(ajax, pagedList.TotalPageCount, pagedList.CurrentPageIndex, null, null, routeName, pagerOptions, routeValues, ajaxOptions, htmlAttributes));
 }
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerOptionsBuilder/Constrctor[@name="PagerOptionsBuilder"]/*'/>
 public PagerOptionsBuilder(PagerOptions pagerOptions)
 {
     _pagerOptions = pagerOptions;
 }
Exemple #21
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.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, pagerOptions, routeName, routeValues, htmlAttributes));
 }