コード例 #1
0
	private static string BuildSortIcon(bool isCurrentSortField, QueryOptions queryOptions)
	{
		string sortIcon = "sort";

		if (isCurrentSortField)
		{
			sortIcon += "-by-alphabet";
			if (queryOptions.SortOrder == SortOrder.DESC.ToString())
				sortIcon += "-alt";
		}

		return string.Format("<span class=\"{0} {1}{2}\"></span>",
			"glyphicon", "glyphicon-", sortIcon);
	}
コード例 #2
0
	public static MvcHtmlString BuildNextPreviousLinks(this HtmlHelper htmlHelper, QueryOptions queryOptions, string actionName)
	{
		var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);

		return new MvcHtmlString(string.Format(
"<nav>" +
"    <ul class=\"pager\">" +
"        <li class=\"previous {0}\">{1}</li>" +
"        <li class=\"next {2}\">{3}</li>" +
"    </ul>" +
"</nav>",
		IsPreviousDisabled(queryOptions),
		BuildPreviousLink(urlHelper, queryOptions, actionName),
		IsNextDisabled(queryOptions),
		BuildNextLink(urlHelper, queryOptions, actionName)
		));
	}
コード例 #3
0
	public static MvcHtmlString BuildSortableLink(this HtmlHelper htmlHelper,
		string fieldName, string actionName, string sortField, QueryOptions queryOptions)
	{
		var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);

		var isCurrentSortField = queryOptions.SortField == sortField;

		return new MvcHtmlString(string.Format("<a href=\"{0}\">{1} {2}</a>",
			urlHelper.Action(actionName,
			new
			{
				SortField = sortField,
				SortOrder = (isCurrentSortField
							&& queryOptions.SortOrder == SortOrder.ASC.ToString())
						? SortOrder.DESC : SortOrder.ASC
			}),
			fieldName,
			BuildSortIcon(isCurrentSortField, queryOptions)));
	}
コード例 #4
0
		public static int CalculateStart(QueryOptions queryOptions)
		{
			return (queryOptions.CurrentPage - 1) * queryOptions.PageSize;
		}
コード例 #5
0
	private static string BuildNextLink(UrlHelper urlHelper, QueryOptions queryOptions, string actionName)
	{
		return string.Format(
			"<a href=\"{0}\">Next <span aria-hidden=\"true\">&rarr;</span></a>",
			urlHelper.Action(actionName, new
			{
				SortOrder = queryOptions.SortOrder,
				SortField = queryOptions.SortField,
				CurrentPage = queryOptions.CurrentPage + 1,
				PageSize = queryOptions.PageSize
			}));
	}
コード例 #6
0
	private static string IsNextDisabled(QueryOptions queryOptions)
	{
		return (queryOptions.CurrentPage == queryOptions.TotalPages)
			? "disabled" : string.Empty;
	}
コード例 #7
0
	private static string IsPreviousDisabled(QueryOptions queryOptions)
	{
		return (queryOptions.CurrentPage == 1)
			? "disabled" : string.Empty;
	}