예제 #1
0
 ///<include file='docs/MvcCorePagerDocs.xml' path='MvcCorePagerDocs/AjaxPager/Method[@name="AjaxOptions"]/*'/>
 public AjaxPager AjaxOptions(Action <MvcAjaxOptionsBuilder> builder)
 {
     if (_ajaxOptions == null)
     {
         _ajaxOptions = new MvcAjaxOptions();
     }
     builder(new MvcAjaxOptionsBuilder(_ajaxOptions));
     return(this);
 }
예제 #2
0
 ///<include file='docs/MvcCorePagerDocs.xml' path='MvcCorePagerDocs/AjaxPager/Constructor[@name="AjaxPager1"]/*'/>
 public AjaxPager(IHtmlHelper html, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     _htmlHelper       = html;
     _totalItemCount   = totalItemCount;
     _pageSize         = pageSize;
     _currentPageIndex = pageIndex;
     _pagerOptions     = pagerOptions;
     _ajaxOptions      = ajaxOptions;
 }
예제 #3
0
        //Ajax pager builder
        internal PagerBuilder(ViewContext viewContext, IUrlHelper urlHelper, int totalPageCount, int pageIndex, PagerOptions pagerOptions,
                              MvcAjaxOptions ajaxOptions)
        {
            _ajaxPagingEnabled = true;
            if (pagerOptions == null)
            {
                pagerOptions = new PagerOptions();
            }
            _urlHelper   = urlHelper;
            _viewContext = viewContext ?? throw new ArgumentNullException("viewContext");
            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;
            }
        }
예제 #4
0
 ///<include file='docs/MvcCorePagerDocs.xml' path='MvcCorePagerDocs/PagerExtensions/Method[@name="AjaxPager4"]/*'/>
 public static AjaxPager AjaxPager(this IHtmlHelper helper, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         throw new ArgumentNullException("pagedList");
     }
     return(AjaxPager(helper, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions, ajaxOptions));
 }
예제 #5
0
 ///<include file='docs/MvcCorePagerDocs.xml' path='MvcCorePagerDocs/PagerExtensions/Method[@name="AjaxPager1"]/*'/>
 public static AjaxPager AjaxPager(this IHtmlHelper helper, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     return(new AjaxPager(helper, totalItemCount, pageSize, pageIndex, pagerOptions, ajaxOptions));
 }
예제 #6
0
 ///<include file='docs/MvcCorePagerDocs.xml' path='MvcCorePagerDocs/AjaxPager/Constructor[@name="AjaxPager2"]/*'/>
 public AjaxPager(IHtmlHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
     : this(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions, ajaxOptions)
 {
 }