Example #1
0
 //Ajax pager builder
 internal PagerBuilder(AjaxHelper helper, string actionName, string controllerName, int totalPageCount,
                       int pageIndex, PagerOptions pagerOptions, string routeName, RouteValueDictionary routeValues,
                       MvcAjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
     : this(null, helper, actionName,
            controllerName, totalPageCount, pageIndex, pagerOptions, routeName, routeValues, ajaxOptions, htmlAttributes)
 {
 }
Example #2
0
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, string routeName, RouteValueDictionary routeValues,
                                   PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     if (pagedList == null)
     {
         return(Pager(ajax, pagerOptions, htmlAttributes));
     }
     return(Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, routeName, pagerOptions, routeValues, ajaxOptions, htmlAttributes));
 }
Example #3
0
 internal PagerBuilder(HtmlHelper html, AjaxHelper ajax, string actionName, string controllerName,
                       int totalPageCount, int pageIndex, PagerOptions pagerOptions, string routeName, RouteValueDictionary routeValues,
                       MvcAjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     _ajaxPagingEnabled = (ajax != null);
     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;
     }
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PagerBuilder"/> class.
 /// </summary>
 /// <param name="html">
 /// The html.
 /// </param>
 /// <param name="ajax">
 /// The ajax.
 /// </param>
 /// <param name="actionName">
 /// The action name.
 /// </param>
 /// <param name="controllerName">
 /// The controller name.
 /// </param>
 /// <param name="totalPageCount">
 /// The total page count.
 /// </param>
 /// <param name="pageIndex">
 /// The page index.
 /// </param>
 /// <param name="pagerOptions">
 /// The pager options.
 /// </param>
 /// <param name="routeName">
 /// The route name.
 /// </param>
 /// <param name="routeValues">
 /// The route values.
 /// </param>
 /// <param name="ajaxOptions">
 /// The ajax options.
 /// </param>
 /// <param name="htmlAttributes">
 /// The html attributes.
 /// </param>
 internal PagerBuilder(HtmlHelper html, AjaxHelper ajax, string actionName, string controllerName, int totalPageCount, int pageIndex, PagerOptions pagerOptions, string routeName, RouteValueDictionary routeValues, MvcAjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     this._ajaxPagingEnabled = (ajax != null);
     if (pagerOptions == null)
     {
         pagerOptions = new PagerOptions();
     }
     this._html           = html;
     this._ajax           = ajax;
     this._actionName     = actionName;
     this._controllerName = controllerName;
     if (pagerOptions.MaxPageIndex == 0 || pagerOptions.MaxPageIndex > totalPageCount)
     {
         this._totalPageCount = totalPageCount;
     }
     else
     {
         this._totalPageCount = pagerOptions.MaxPageIndex;
     }
     this._pageIndex      = pageIndex;
     this._pagerOptions   = pagerOptions;
     this._routeName      = routeName;
     this._routeValues    = routeValues;
     this._ajaxOptions    = ajaxOptions;
     this._htmlAttributes = htmlAttributes;
     this._startPageIndex = pageIndex - pagerOptions.NumericPagerItemCount / 2;
     if (this._startPageIndex + pagerOptions.NumericPagerItemCount > this._totalPageCount)
     {
         this._startPageIndex = this._totalPageCount + 1 - pagerOptions.NumericPagerItemCount;
     }
     if (this._startPageIndex < 1)
     {
         this._startPageIndex = 1;
     }
     this._endPageIndex = this._startPageIndex + this._pagerOptions.NumericPagerItemCount - 1;
     if (this._endPageIndex > this._totalPageCount)
     {
         this._endPageIndex = this._totalPageCount;
     }
 }
Example #5
0
 /// <summary>
 /// The pager.
 /// </summary>
 /// <param name="ajax">
 /// The ajax.
 /// </param>
 /// <param name="pagedList">
 /// The paged list.
 /// </param>
 /// <param name="pagerOptions">
 /// The pager options.
 /// </param>
 /// <param name="ajaxOptions">
 /// The ajax options.
 /// </param>
 /// <param name="htmlAttributes">
 /// The html attributes.
 /// </param>
 /// <returns>
 /// The <see cref="MvcHtmlString"/>.
 /// </returns>
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions, object htmlAttributes)
 {
     if (pagedList == null)
     {
         return(PagerHelper.Pager(ajax, pagerOptions, new RouteValueDictionary(htmlAttributes)));
     }
     return(ajax.Pager(pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions, htmlAttributes));
 }
Example #6
0
 /// <summary>
 /// The pager.
 /// </summary>
 /// <param name="ajax">
 /// The ajax.
 /// </param>
 /// <param name="pagedList">
 /// The paged list.
 /// </param>
 /// <param name="pagerOptions">
 /// The pager options.
 /// </param>
 /// <param name="ajaxOptions">
 /// The ajax options.
 /// </param>
 /// <returns>
 /// The <see cref="MvcHtmlString"/>.
 /// </returns>
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     if (pagedList != null)
     {
         return(ajax.Pager(pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions, null));
     }
     return(PagerHelper.Pager(ajax, pagerOptions, null));
 }
Example #7
0
        /// <summary>
        /// The pager.
        /// </summary>
        /// <param name="ajax">
        /// The ajax.
        /// </param>
        /// <param name="totalItemCount">
        /// The total item count.
        /// </param>
        /// <param name="pageSize">
        /// The page size.
        /// </param>
        /// <param name="pageIndex">
        /// The page index.
        /// </param>
        /// <param name="actionName">
        /// The action name.
        /// </param>
        /// <param name="controllerName">
        /// The controller name.
        /// </param>
        /// <param name="routeName">
        /// The route name.
        /// </param>
        /// <param name="pagerOptions">
        /// The pager options.
        /// </param>
        /// <param name="routeValues">
        /// The route values.
        /// </param>
        /// <param name="ajaxOptions">
        /// The ajax options.
        /// </param>
        /// <param name="htmlAttributes">
        /// The html attributes.
        /// </param>
        /// <returns>
        /// The <see cref="MvcHtmlString"/>.
        /// </returns>
        public static MvcHtmlString Pager(this AjaxHelper ajax, int totalItemCount, int pageSize, int pageIndex, string actionName, string controllerName, string routeName, PagerOptions pagerOptions, RouteValueDictionary routeValues, MvcAjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
        {
            int          totalPageCount = (int)Math.Ceiling((double)totalItemCount / (double)pageSize);
            PagerBuilder builder        = new PagerBuilder(ajax, actionName, controllerName, totalPageCount, pageIndex, pagerOptions, routeName, routeValues, ajaxOptions, htmlAttributes);

            return(builder.RenderPager());
        }
Example #8
0
 public static MvcHtmlString Pager(this AjaxHelper ajax, IPagedList pagedList, MvcAjaxOptions ajaxOptions)
 {
     return(pagedList == null?Pager(ajax, (PagerOptions)null, null) : Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, null, null, ajaxOptions, null));
 }