Exemplo n.º 1
0
		/// <summary>
		/// Displays a configurable paging control for instances of PagedList.
		/// </summary>
		/// <param name="html">This method is meant to hook off HtmlHelper as an extension method.</param>
		/// <param name="list">The PagedList to use as the data source.</param>
		/// <param name="formId">Id of the firm, which is used to submit data.</param>
		/// <param name="routeValues">Additional parameters to pass to server.</param>
		/// <param name="actionUrl">Url for the form where it should submit.</param>
		/// <param name="validation">Should or not form validate data in form.</param>
		/// <returns></returns>
		public static MvcHtmlString DVSPagedListPager(this System.Web.Mvc.HtmlHelper html, IPagedList list,
			string formId, Func<int, RouteValueDictionary> routeValues, string actionUrl, ValidationType validation = ValidationType.None)
		{
			if (list == null) throw new ArgumentNullException("list");
			if (routeValues == null) throw new ArgumentNullException("routeValues");
			if (String.IsNullOrWhiteSpace(actionUrl)) throw new ArgumentNullException("actionUrl");
			if (String.IsNullOrWhiteSpace(formId)) throw new ArgumentNullException("formId");

			var options = new PagedListRenderOptions
			{
				LinkToPreviousPageFormat = "<",
				LinkToNextPageFormat = ">",
				DisplayLinkToFirstPage = true,
				LinkToFirstPageFormat = "1",
				DisplayLinkToLastPage = true,
				LinkToLastPageFormat = list.PageCount.ToString(),
				EllipsesFormat = "..",
				MaximumPageNumbersToDisplay = 5,
				ContainerDivClasses = new string[] { "PagedList-pager" }
			};
			var jsHelper = new JavaScriptHelper();
			Func<int, string> pageAction = page => jsHelper.GetSubmitScript(formId, routeValues(page), actionUrl, validation);

			return DVSPagedListPager(html, list, pageAction, options);
		}