public FluentMvcGridPagination() { _enabled = true; _numericLinksCount = 5; _pageIndex = 1; _pageSize = 10; _paginationInfo = true; _paginationSizing = PaginationSizing.Normal; _paginationAligment = PaginationAligment.Left; _href = true; }
public static HtmlString GetDefaultPagination( this HtmlHelper htmlHelper, int pageIndex, int totalCount, int pageSize, PaginationSizing paginationSizing, PaginationAligment paginationAligment, int numericLinksCount, bool paginationInfo, object htmlAttributes, BootstrapVersion bootstrapVersion, string onClick, bool href, Uri currentUrl, string[] removedParameters, Dictionary <string, string> addedParameters) { return(Pagination.GetDefaultPagination(pageIndex, totalCount, pageSize, paginationSizing, paginationAligment, numericLinksCount, paginationInfo, htmlAttributes, bootstrapVersion, onClick, href, currentUrl, removedParameters, addedParameters)); }
public static HtmlString GetDefaultPagination( this HtmlHelper htmlHelper, int pageIndex, int totalCount, int pageSize, PaginationSizing paginationSizing, PaginationAligment paginationAligment, int numericLinksCount, bool paginationInfo, object htmlAttributes, BootstrapVersion bootstrapVersion, string onClick, bool href, Uri currentUrl, string[] removedParameters, Dictionary<string, string> addedParameters) { return Pagination.GetDefaultPagination(pageIndex, totalCount, pageSize, paginationSizing, paginationAligment, numericLinksCount, paginationInfo, htmlAttributes, bootstrapVersion, onClick, href, currentUrl, removedParameters, addedParameters); }
public FluentMvcGridPagination Sizing(PaginationSizing value) { _paginationSizing = value; return this; }
public FluentMvcGridPagination Sizing(PaginationSizing value) { _paginationSizing = value; return(this); }
public static HtmlString GetDefaultPagination(int pageIndex, int totalCount, int pageSize, PaginationSizing paginationSizing, PaginationAligment paginationAligment, int numericLinksCount, bool paginationInfo, object htmlAttributes, BootstrapVersion bootstrapVersion, string onClick, bool href, Uri currentUrl, string[] removedParameters, Dictionary<string, string> addedParameters) { if (currentUrl == null) { currentUrl = HttpContext.Current.Request.Url; } var pageCount = CalculatePageCount(pageSize, totalCount); if (pageCount == 1) { return new HtmlString(""); } var div = new TagBuilder("div"); var ul = new TagBuilder("ul"); TagBuilder parentTag; if (bootstrapVersion == BootstrapVersion.Bootstrap2) { div.AddCssClass("pagination"); if (paginationAligment != PaginationAligment.Left) { div.AddCssClass(paginationAligment == PaginationAligment.Center ? "pagination-centered" : "pagination-right"); } parentTag = div; } else { ul.AddCssClass("pagination"); parentTag = ul; } var attributes = (IDictionary<string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (attributes != null) { if (attributes.ContainsKey("class")) { parentTag.AddCssClass(attributes["class"].ToString()); } parentTag.MergeAttributes(attributes); } switch (paginationSizing) { case PaginationSizing.Large: parentTag.AddCssClass("pagination-" + (bootstrapVersion == BootstrapVersion.Bootstrap2 ? "pagination-large" : "pagination-lg")); break; case PaginationSizing.Small: parentTag.AddCssClass("pagination-" + (bootstrapVersion == BootstrapVersion.Bootstrap2 ? "pagination-small" : "pagination-sm")); break; case PaginationSizing.Mini: if (bootstrapVersion == BootstrapVersion.Bootstrap2) { parentTag.AddCssClass("pagination pagination-mini"); } break; } var liClass = pageIndex == 1 ? "disabled" : ""; var parameters = Utilities.ParseQueryString(currentUrl.Query); RemoveParameters(parameters, removedParameters); AddParameters(parameters, addedParameters); var page = 1; parameters["page"] = page.ToString(); var path = currentUrl.LocalPath; var url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem("«", url, liClass, FluentMvcGridResources.First, onClick, href, page); var num = pageCount - 1; var num1 = pageIndex + numericLinksCount / 2; var num2 = num1 - numericLinksCount + 1; if (num1 > num) { num2 = num2 - (num1 - num); num1 = num; } if (num2 < 0) { num1 = Math.Min(num1 + -num2, num); num2 = 0; } for (var i = num2; i <= num1; i++) { var j = i + 1; var text = j.ToString(CultureInfo.InvariantCulture); liClass = pageIndex == j ? "active" : ""; if (j != pageIndex) { page = j; parameters["page"] = page.ToString(); url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem(text, url, liClass, null, onClick, href, page); } else { url = ""; ul.InnerHtml += GetPaginationItem(text, url, liClass, null, onClick, href, null); } } liClass = pageIndex == pageCount ? "disabled" : ""; page = pageCount; parameters["page"] = page.ToString(); url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem("»", url, liClass, FluentMvcGridResources.Last, onClick, href, page); if (paginationInfo) { var info = string.Format(FluentMvcGridResources.PaginationInfo, pageIndex, pageCount, totalCount); ul.InnerHtml += string.Format("<li class='disabled'><span>{0}</span></li>", info); } if (bootstrapVersion == BootstrapVersion.Bootstrap2) { div.InnerHtml = ul.ToString(); return new HtmlString(div.ToString()); } return new HtmlString(ul.ToString()); }
public static HtmlString GetDefaultPagination(int pageIndex, int totalCount, int pageSize, PaginationSizing paginationSizing, PaginationAligment paginationAligment, int numericLinksCount, bool paginationInfo, object htmlAttributes, BootstrapVersion bootstrapVersion, string onClick, bool href, Uri currentUrl, string[] removedParameters, Dictionary <string, string> addedParameters) { if (currentUrl == null) { currentUrl = HttpContext.Current.Request.Url; } var pageCount = CalculatePageCount(pageSize, totalCount); if (pageCount == 1) { return(new HtmlString("")); } var div = new TagBuilder("div"); var ul = new TagBuilder("ul"); TagBuilder parentTag; if (bootstrapVersion == BootstrapVersion.Bootstrap2) { div.AddCssClass("pagination"); if (paginationAligment != PaginationAligment.Left) { div.AddCssClass(paginationAligment == PaginationAligment.Center ? "pagination-centered" : "pagination-right"); } parentTag = div; } else { ul.AddCssClass("pagination"); parentTag = ul; } var attributes = (IDictionary <string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (attributes != null) { if (attributes.ContainsKey("class")) { parentTag.AddCssClass(attributes["class"].ToString()); } parentTag.MergeAttributes(attributes); } switch (paginationSizing) { case PaginationSizing.Large: parentTag.AddCssClass("pagination-" + (bootstrapVersion == BootstrapVersion.Bootstrap2 ? "pagination-large" : "pagination-lg")); break; case PaginationSizing.Small: parentTag.AddCssClass("pagination-" + (bootstrapVersion == BootstrapVersion.Bootstrap2 ? "pagination-small" : "pagination-sm")); break; case PaginationSizing.Mini: if (bootstrapVersion == BootstrapVersion.Bootstrap2) { parentTag.AddCssClass("pagination pagination-mini"); } break; } var liClass = pageIndex == 1 ? "disabled" : ""; var parameters = Utilities.ParseQueryString(currentUrl.Query); RemoveParameters(parameters, removedParameters); AddParameters(parameters, addedParameters); var page = 1; parameters["page"] = page.ToString(); var path = currentUrl.LocalPath; var url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem("«", url, liClass, FluentMvcGridResources.First, onClick, href, page); var num = pageCount - 1; var num1 = pageIndex + numericLinksCount / 2; var num2 = num1 - numericLinksCount + 1; if (num1 > num) { num2 = num2 - (num1 - num); num1 = num; } if (num2 < 0) { num1 = Math.Min(num1 + -num2, num); num2 = 0; } for (var i = num2; i <= num1; i++) { var j = i + 1; var text = j.ToString(CultureInfo.InvariantCulture); liClass = pageIndex == j ? "active" : ""; if (j != pageIndex) { page = j; parameters["page"] = page.ToString(); url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem(text, url, liClass, null, onClick, href, page); } else { url = ""; ul.InnerHtml += GetPaginationItem(text, url, liClass, null, onClick, href, null); } } liClass = pageIndex == pageCount ? "disabled" : ""; page = pageCount; parameters["page"] = page.ToString(); url = Utilities.AppendParametersToUrl(path, parameters); ul.InnerHtml += GetPaginationItem("»", url, liClass, FluentMvcGridResources.Last, onClick, href, page); if (paginationInfo) { var info = string.Format(FluentMvcGridResources.PaginationInfo, pageIndex, pageCount, totalCount); ul.InnerHtml += string.Format("<li class='disabled'><span>{0}</span></li>", info); } if (bootstrapVersion == BootstrapVersion.Bootstrap2) { div.InnerHtml = ul.ToString(); return(new HtmlString(div.ToString())); } return(new HtmlString(ul.ToString())); }