void AddPageNumbers(ICollection<PagerItem> collection) { for (var pageIndex = _startPageIndex; pageIndex <= _endPageIndex; pageIndex++) { var text = pageIndex.ToString(); if (pageIndex == _pageIndex && _pagerOptions.CurrentPageNumberFormatString.IsNotNullOrEmpty()) text = String.Format(_pagerOptions.CurrentPageNumberFormatString, text); else if (_pagerOptions.PageNumberFormatString.IsNotNullOrEmpty()) text = String.Format(_pagerOptions.PageNumberFormatString, text); var pagerItem = new PagerItem(text, pageIndex, false, PagerItemType.NumericPage); collection.Add(pagerItem); } }
void AddMoreBefore(ICollection<PagerItem> collection) { if (_startPageIndex > 1 && _pagerOptions.ShowMorePagerItems) { var index = _startPageIndex - 1; if (index < 1) index = 1; PagerItem item = new PagerItem(_pagerOptions.MorePageText, index, false, PagerItemType.MorePage); collection.Add(item); } }
void AddNext(ICollection<PagerItem> collection) { var pagerItem = new PagerItem(_pagerOptions.NextPageText, _pageIndex + 1, _pageIndex >= _NoOfPages, PagerItemType.NextPage); if (!pagerItem.Disabled || (pagerItem.Disabled && _pagerOptions.ShowDisabledPagerItems)) collection.Add(pagerItem); }
private void AddMoreAfter(ICollection<PagerItem> results) { if (this.endPageIndex < this.totalPageCountGang) { int pageIndex = this.startPageIndexGang + this.pagerOpitonGang.NumericPagerItemCount; if (pageIndex > this.totalPageCountGang) { pageIndex = this.totalPageCountGang; } PagerItem item = new PagerItem(this.pagerOpitonGang.MorePageText, pageIndex, false, PagerItemType.MorePage); results.Add(item); } }
void AddMoreAfter(ICollection<PagerItem> collection) { if (_endPageIndex < _NoOfPages) { var index = _startPageIndex + _pagerOptions.NumericPagerItemCount; if (index > _NoOfPages) { index = _NoOfPages; } var item = new PagerItem(_pagerOptions.MorePageText, index, false, PagerItemType.MorePage); collection.Add(item); } }
String GenerateAnchor(PagerItem item) { if (_msAjaxPaging) { var routeValues = GetCurrentRouteValues(_ajaxHelper.ViewContext); if (item.PageIndex == 0) routeValues[_pagerOptions.PageIndexParameterName] = ScriptPageIndexName; else routeValues[_pagerOptions.PageIndexParameterName] = item.PageIndex; return _routeName.IsNullOrEmpty() ? _ajaxHelper.RouteLink(item.Text, routeValues, _ajaxOptions).ToString() : _ajaxHelper.RouteLink(item.Text, _routeName, routeValues, _ajaxOptions).ToString(); } var url = GenerateUrl(item.PageIndex); if (_pagerOptions.UseJqueryAjax) { var ehBuilder = new StringBuilder(); //ignore OnSuccess property if (_ajaxOptions.OnFailure.IsNotNullOrEmpty() || _ajaxOptions.OnBegin.IsNotNullOrEmpty()) { ehBuilder.Append("$.ajax({url:$(this).attr(\'href\'),success:function(data,status,xhr){$(\'#"); ehBuilder.Append(_ajaxOptions.UpdateTargetId).Append("\').html(data);}"); if (_ajaxOptions.OnFailure.IsNotNullOrEmpty()) ehBuilder.Append(",error:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnFailure)); if (_ajaxOptions.OnBegin.IsNotNullOrEmpty()) ehBuilder.Append(",beforeSend:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnBegin)); if (_ajaxOptions.OnComplete.IsNotNullOrEmpty()) ehBuilder.Append(",complete:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete)); ehBuilder.Append("});return false;"); } else { ehBuilder.Append("$(\'#").Append(_ajaxOptions.UpdateTargetId); ehBuilder.Append("\').load($(this).attr(\'href\')"); if (_ajaxOptions.OnComplete.IsNotNullOrEmpty()) ehBuilder.Append(",").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete)); ehBuilder.Append(");return false;"); } return url.IsNullOrEmpty() ? _htmlHelper.Encode(item.Text) : String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" onclick=\"{1}\">{2}</a>", GenerateUrl(item.PageIndex), ehBuilder, item.Text); } return String.Format("<a href=\"{0}\" onclick=\"{1}\"></a>", url, "window.open(this.attributes.getNamedItem('href').value,'_self')"); }
String GenerateMsAjaxPagerElement(PagerItem item) { if (item.PageIndex == _pageIndex && !item.Disabled) //current page index return CreateWrappedPagerElement(item, item.Text); if (item.Disabled) return CreateWrappedPagerElement(item, String.Format("<a disabled=\"disabled\">{0}</a>", item.Text)); // return null if current page index less than 1 or large than total page count if (item.PageIndex < 1 || item.PageIndex > _NoOfPages) return null; return CreateWrappedPagerElement(item, GenerateAnchor(item)); }
private string GenerateAnchor(PagerItem item) { if (this.mmsAjaxPagingGang) { RouteValueDictionary currentRouteValues = this.GetCurrentRouteValues(this.ajaxGang.ViewContext); if (item.PageIndex == 0) { currentRouteValues.Add(this.pagerOpitonGang.PageIndexParameterName, "_MvcPager_PageIndex_"); } else { currentRouteValues.Add(this.pagerOpitonGang.PageIndexParameterName, item.PageIndex); } if (!string.IsNullOrEmpty(this.routeNameGang)) { return this.ajaxGang.RouteLink(item.Text, this.routeNameGang, currentRouteValues, this.ajaxOptionGang).ToString(); } return this.ajaxGang.RouteLink(item.Text, currentRouteValues, this.ajaxOptionGang).ToString(); } string str = this.GenerateUrl(item.PageIndex); if (!this.pagerOpitonGang.UseJqueryAjax) { return ("<a href=\"" + str + "\" onclick=\"window.open(this.attributes.getNamedItem('href').value,'_self')\"></a>"); } StringBuilder builder = new StringBuilder(); if ((!string.IsNullOrEmpty(this.ajaxOptionGang.OnFailure) || !string.IsNullOrEmpty(this.ajaxOptionGang.OnBegin)) || (!string.IsNullOrEmpty(this.ajaxOptionGang.OnComplete) && (this.ajaxOptionGang.HttpMethod.ToUpper() != "GET"))) { builder.Append("$.ajax({type:'").Append((this.ajaxOptionGang.HttpMethod.ToUpper() == "GET") ? "get" : "post"); builder.Append("',url:$(this).attr('href')"); if (!string.IsNullOrEmpty(this.pagerOpitonGang.AjaxPara)) { builder.Append(",data:" + this.pagerOpitonGang.AjaxPara); } builder.Append(",success:function(data,status,xhr){$('#"); builder.Append(this.ajaxOptionGang.UpdateTargetId).Append("').html(data);}"); if (!string.IsNullOrEmpty(this.ajaxOptionGang.OnFailure)) { builder.Append(",error:").Append(HttpUtility.HtmlAttributeEncode(this.ajaxOptionGang.OnFailure)); } if (!string.IsNullOrEmpty(this.ajaxOptionGang.OnBegin)) { builder.Append(",beforeSend:").Append(HttpUtility.HtmlAttributeEncode(this.ajaxOptionGang.OnBegin)); } if (!string.IsNullOrEmpty(this.ajaxOptionGang.OnComplete)) { builder.Append(",complete:").Append(HttpUtility.HtmlAttributeEncode(this.ajaxOptionGang.OnComplete)); } builder.Append("});return false;"); } else if (this.ajaxOptionGang.HttpMethod.ToUpper() == "GET") { builder.Append("$('#").Append(this.ajaxOptionGang.UpdateTargetId); builder.Append("').load($(this).attr('href')"); if (!string.IsNullOrEmpty(this.pagerOpitonGang.AjaxPara)) { builder.Append("," + this.pagerOpitonGang.AjaxPara); } if (!string.IsNullOrEmpty(this.ajaxOptionGang.OnComplete)) { builder.Append(",").Append(HttpUtility.HtmlAttributeEncode(this.ajaxOptionGang.OnComplete)); } builder.Append(");return false;"); } else { builder.Append("$.post($(this).attr('href'),"); if (!string.IsNullOrEmpty(this.pagerOpitonGang.AjaxPara)) { builder.Append(this.pagerOpitonGang.AjaxPara); } builder.Append(",function(data) {$('#"); builder.Append(this.ajaxOptionGang.UpdateTargetId); builder.Append("').html(data);});return false;"); } if (!string.IsNullOrEmpty(str)) { return string.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" onclick=\"{1}\">{2}</a>", new object[] { str, builder, item.Text }); } return this.htmlGang.Encode(item.Text); }
private MvcHtmlString GenerateJqAjaxPagerElement(PagerItem item) { if (item.Disabled) { return this.CreateWrappedPagerElement(item, string.Format("<a style=\"color:#808080; text-decoration:none\" disabled=\"disabled\">{0}</a>", item.Text)); } return this.CreateWrappedPagerElement(item, this.GenerateAnchor(item)); }
private void AddPrevious(ICollection<PagerItem> results) { PagerItem item = new PagerItem(this.pagerOpitonGang.PrevPageText, this.pageIndexGang - 1, this.pageIndexGang == 1, PagerItemType.PrevPage); if (!item.Disabled || (item.Disabled && this.pagerOpitonGang.ShowDisabledPagerItems)) { results.Add(item); } }
private MvcHtmlString CreateWrappedPagerElement(PagerItem item, string el) { string str = el; switch (item.Type) { case PagerItemType.FirstPage: case PagerItemType.NextPage: case PagerItemType.PrevPage: case PagerItemType.LastPage: if (!string.IsNullOrEmpty(this.pagerOpitonGang.NavigationPagerItemWrapperFormatString) || !string.IsNullOrEmpty(this.pagerOpitonGang.PagerItemWrapperFormatString)) { str = string.Format(this.pagerOpitonGang.NavigationPagerItemWrapperFormatString ?? this.pagerOpitonGang.PagerItemWrapperFormatString, el); } break; case PagerItemType.MorePage: if (!string.IsNullOrEmpty(this.pagerOpitonGang.MorePagerItemWrapperFormatString) || !string.IsNullOrEmpty(this.pagerOpitonGang.PagerItemWrapperFormatString)) { str = string.Format(this.pagerOpitonGang.MorePagerItemWrapperFormatString ?? this.pagerOpitonGang.PagerItemWrapperFormatString, el); } break; case PagerItemType.NumericPage: if ((item.PageIndex != this.pageIndexGang) || (string.IsNullOrEmpty(this.pagerOpitonGang.CurrentPagerItemWrapperFormatString) && string.IsNullOrEmpty(this.pagerOpitonGang.PagerItemWrapperFormatString))) { if (!string.IsNullOrEmpty(this.pagerOpitonGang.NumericPagerItemWrapperFormatString) || !string.IsNullOrEmpty(this.pagerOpitonGang.PagerItemWrapperFormatString)) { str = string.Format(this.pagerOpitonGang.NumericPagerItemWrapperFormatString ?? this.pagerOpitonGang.PagerItemWrapperFormatString, el); } break; } str = string.Format(this.pagerOpitonGang.CurrentPagerItemWrapperFormatString ?? this.pagerOpitonGang.PagerItemWrapperFormatString, el); break; } return MvcHtmlString.Create(str + this.pagerOpitonGang.SeparatorHtml); }
private void AddPageNumbers(ICollection<PagerItem> results) { for (int i = this.startPageIndexGang; i <= this.endPageIndex; i++) { string str = i.ToString(); if ((i == this.pageIndexGang) && !string.IsNullOrEmpty(this.pagerOpitonGang.CurrentPageNumberFormatString)) { str = string.Format(this.pagerOpitonGang.CurrentPageNumberFormatString, str); } else if (!string.IsNullOrEmpty(this.pagerOpitonGang.PageNumberFormatString)) { str = string.Format(this.pagerOpitonGang.PageNumberFormatString, str); } PagerItem item = new PagerItem(str, i, false, PagerItemType.NumericPage); results.Add(item); } }
private void AddNext(ICollection<PagerItem> results) { PagerItem item = new PagerItem(this.pagerOpitonGang.NextPageText, this.pageIndexGang + 1, this.pageIndexGang >= this.totalPageCountGang, PagerItemType.NextPage); if (!item.Disabled || (item.Disabled && this.pagerOpitonGang.ShowDisabledPagerItems)) { results.Add(item); } }
private void AddMoreBefore(ICollection<PagerItem> results) { if ((this.startPageIndexGang > 1) && this.pagerOpitonGang.ShowMorePagerItems) { int pageIndex = this.startPageIndexGang - 1; if (pageIndex < 1) { pageIndex = 1; } PagerItem item = new PagerItem(this.pagerOpitonGang.MorePageText, pageIndex, false, PagerItemType.MorePage); results.Add(item); } }
// --- void AddPrevious(ICollection<PagerItem> collection) { var pagerItem = new PagerItem(_pagerOptions.PrevPageText, _pageIndex - 1, _pageIndex == 1, PagerItemType.PrevPage); if (!pagerItem.Disabled || (pagerItem.Disabled && _pagerOptions.ShowDisabledPagerItems)) collection.Add(pagerItem); }
private MvcHtmlString GenerateMsAjaxPagerElement(PagerItem item) { if ((item.PageIndex == this.pageIndexGang) && !item.Disabled) { return this.CreateWrappedPagerElement(item, item.Text); } if (item.Disabled) { return this.CreateWrappedPagerElement(item, string.Format("<a style=\"color:#808080; text-decoration:none\" disabled=\"disabled\">{0}</a>", item.Text)); } if ((item.PageIndex >= 1) && (item.PageIndex <= this.totalPageCountGang)) { return this.CreateWrappedPagerElement(item, this.GenerateAnchor(item)); } return null; }
String CreateWrappedPagerElement(PagerItem item, String el) { var navStr = el; switch (item.Type) { case PagerItemType.FirstPage: case PagerItemType.LastPage: case PagerItemType.NextPage: case PagerItemType.PrevPage: if (_pagerOptions.NavigationPagerItemWrapperFormatString.IsNotNullOrEmpty() || _pagerOptions.PagerItemWrapperFormatString.IsNotNullOrEmpty()) navStr = String.Format( _pagerOptions.NavigationPagerItemWrapperFormatString ?? _pagerOptions.PagerItemWrapperFormatString, el); break; case PagerItemType.MorePage: if (_pagerOptions.MorePagerItemWrapperFormatString.IsNotNullOrEmpty() || _pagerOptions.PagerItemWrapperFormatString.IsNotNullOrEmpty()) navStr = String.Format( _pagerOptions.MorePagerItemWrapperFormatString ?? _pagerOptions.PagerItemWrapperFormatString, el); break; case PagerItemType.NumericPage: if (item.PageIndex == _pageIndex && (_pagerOptions.CurrentPagerItemWrapperFormatString.IsNotNullOrEmpty() || _pagerOptions.PagerItemWrapperFormatString.IsNotNullOrEmpty())) //current page navStr = String.Format( _pagerOptions.CurrentPagerItemWrapperFormatString ?? _pagerOptions.PagerItemWrapperFormatString, el); else if (_pagerOptions.NumericPagerItemWrapperFormatString.IsNotNullOrEmpty() || _pagerOptions.PagerItemWrapperFormatString.IsNotNullOrEmpty()) navStr = String.Format( _pagerOptions.NumericPagerItemWrapperFormatString ?? _pagerOptions.PagerItemWrapperFormatString, el); break; } return navStr + _pagerOptions.SeparatorHtml; }
private MvcHtmlString GeneratePagerElement(PagerItem item) { string str = this.GenerateUrl(item.PageIndex); if (item.Disabled) { return this.CreateWrappedPagerElement(item, string.Format("<a style=\"color:#808080; text-decoration:none\" disabled=\"disabled\">{0}</a>", item.Text)); } return this.CreateWrappedPagerElement(item, string.IsNullOrEmpty(str) ? this.htmlGang.Encode(item.Text) : string.Format("<a href='{0}'>{1}</a>", str, item.Text)); }
String GenerateJqAjaxPagerElement(PagerItem item) { if (item.Disabled) return CreateWrappedPagerElement(item, String.Format("<a disabled=\"disabled\">{0}</a>", item.Text)); return CreateWrappedPagerElement(item, GenerateAnchor(item)); }
void AddFirst(ICollection<PagerItem> collection) { PagerItem pagerItem = new PagerItem(_pagerOptions.FirstPageText, 1, _pageIndex == 1, PagerItemType.FirstPage); if (!pagerItem.Disabled || (pagerItem.Disabled && _pagerOptions.ShowDisabledPagerItems)) collection.Add(pagerItem); }
String GeneratePagerElement(PagerItem item) { //pager item link var url = GenerateUrl(item.PageIndex); if (item.Disabled) //first,last,next or previous page return CreateWrappedPagerElement(item, String.Format("<a disabled=\"disabled\">{0}</a>", item.Text)); return CreateWrappedPagerElement(item, url.IsNullOrEmpty() ? _htmlHelper.Encode(item.Text) : String.Format("<a href='{0}'>{1}</a>", url, item.Text)); }
String GenerateAnchor(PagerItem item) { if (_msAjaxPaging) { var routeValues = GetCurrentRouteValues(_ajaxHelper.ViewContext); if (item.PageIndex == 0) { routeValues[_pagerOptions.PageIndexParameterName] = ScriptPageIndexName; } else { routeValues[_pagerOptions.PageIndexParameterName] = item.PageIndex; } return(_routeName.IsNullOrEmpty() ? _ajaxHelper.RouteLink(item.Text, routeValues, _ajaxOptions).ToString() : _ajaxHelper.RouteLink(item.Text, _routeName, routeValues, _ajaxOptions).ToString()); } var url = GenerateUrl(item.PageIndex); if (_pagerOptions.UseJqueryAjax) { var ehBuilder = new StringBuilder(); //ignore OnSuccess property if (_ajaxOptions.OnFailure.IsNotNullOrEmpty() || _ajaxOptions.OnBegin.IsNotNullOrEmpty()) { ehBuilder.Append("$.ajax({url:$(this).attr(\'href\'),success:function(data,status,xhr){$(\'#"); ehBuilder.Append(_ajaxOptions.UpdateTargetId).Append("\').html(data);}"); if (_ajaxOptions.OnFailure.IsNotNullOrEmpty()) { ehBuilder.Append(",error:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnFailure)); } if (_ajaxOptions.OnBegin.IsNotNullOrEmpty()) { ehBuilder.Append(",beforeSend:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnBegin)); } if (_ajaxOptions.OnComplete.IsNotNullOrEmpty()) { ehBuilder.Append(",complete:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete)); } ehBuilder.Append("});return false;"); } else { ehBuilder.Append("$(\'#").Append(_ajaxOptions.UpdateTargetId); ehBuilder.Append("\').load($(this).attr(\'href\')"); if (_ajaxOptions.OnComplete.IsNotNullOrEmpty()) { ehBuilder.Append(",").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete)); } ehBuilder.Append(");return false;"); } return(url.IsNullOrEmpty() ? _htmlHelper.Encode(item.Text) : String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" onclick=\"{1}\">{2}</a>", GenerateUrl(item.PageIndex), ehBuilder, item.Text)); } return(String.Format("<a href=\"{0}\" onclick=\"{1}\"></a>", url, "window.open(this.attributes.getNamedItem('href').value,'_self')")); }