Beispiel #1
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;
        }
Beispiel #2
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/AjaxPager/Method[@name="AjaxOptions"]/*'/>
 public AjaxPager AjaxOptions(Action<MvcAjaxOptionsBuilder> builder)
 {
     if (_ajaxOptions == null)
     {
         _ajaxOptions = new MvcAjaxOptions();
     }
     builder(new MvcAjaxOptionsBuilder(_ajaxOptions));
     return this;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/AjaxPager/Method[@name="AjaxOptions"]/*'/>
 public AjaxPager AjaxOptions(Action <MvcAjaxOptionsBuilder> builder)
 {
     if (_ajaxOptions == null)
     {
         _ajaxOptions = new MvcAjaxOptions();
     }
     builder(new MvcAjaxOptionsBuilder(_ajaxOptions));
     return(this);
 }
Beispiel #5
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;
 }
        //Ajax pager builder
        internal PagerBuilder(AjaxHelper ajaxHelper, int totalPageCount, int pageIndex, int totalItemCount, 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;
            _totalItemCount = totalItemCount;
            _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;
            }
        }
Beispiel #7
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerExtensions/Method[@name="AjaxPager4"]/*'/>
 public static AjaxPager Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         throw new ArgumentNullException("pagedList");
     }
     return(Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions, ajaxOptions));
 }
Beispiel #8
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerExtensions/Method[@name="AjaxPager1"]/*'/>
 public static AjaxPager Pager(this AjaxHelper ajax, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     return(new AjaxPager(ajax, totalItemCount, pageSize, pageIndex, pagerOptions, ajaxOptions));
 }
Beispiel #9
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) { }
Beispiel #10
0
 /// <inheritdoc />
 /// <include file="MvcPagerDocs.xml" path="MvcPagerDocs/AjaxPager/Constructor[@name=&quot;AjaxPager2&quot;]/*" />
 public AjaxPager(AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
     : this(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, pagerOptions, ajaxOptions)
 {
 }
Beispiel #11
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerExtensions/Method[@name="AjaxPager4"]/*'/>
 public static AjaxPager Pager(this AjaxHelper ajax, IPagedList pagedList, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     if (pagedList == null)
     {
         throw new ArgumentNullException("pagedList");
     }
     return Pager(ajax, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex,pagerOptions, ajaxOptions);
 }
Beispiel #12
0
 ///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PagerExtensions/Method[@name="AjaxPager1"]/*'/>
 public static AjaxPager Pager(this AjaxHelper ajax, int totalItemCount, int pageSize, int pageIndex, PagerOptions pagerOptions, MvcAjaxOptions ajaxOptions)
 {
     return new AjaxPager(ajax, totalItemCount, pageSize, pageIndex, pagerOptions, ajaxOptions);
 }