public static string SimpleArchivePager <T>(this HtmlHelper htmlHelper, IPageOfList <T> pageOfAList, string routeName, object values, string previousText, string nextText, bool alwaysShowPreviousAndNext) { if (pageOfAList.TotalPageCount < 2) { return(""); } StringBuilder sb = new StringBuilder(50); ViewContext viewContext = htmlHelper.ViewContext; RouteValueDictionary rvd = new RouteValueDictionary(); foreach (KeyValuePair <string, object> item in viewContext.RouteData.Values) { rvd.Add(item.Key, item.Value); } UrlHelper urlHelper = new UrlHelper(viewContext.RequestContext); rvd.Remove("controller"); rvd.Remove("action"); rvd.Remove("id"); if (values != null) { RouteValueDictionary rvd2 = new RouteValueDictionary(values); foreach (KeyValuePair <string, object> item in rvd2) { rvd[item.Key] = item.Value; } } ArchiveData archiveData = new ArchiveData(rvd["archiveData"] as string); sb.Append("<div class=\"pager\">"); if (pageOfAList.PageIndex < pageOfAList.TotalPageCount - 1 || alwaysShowPreviousAndNext) { archiveData.Page = pageOfAList.PageIndex + 2; rvd["archiveData"] = archiveData.ToString(); sb.AppendFormat("<a href=\"{1}{2}\" class=\"next\">{0}</a>", nextText, urlHelper.RouteUrl(routeName, rvd), viewContext.HttpContext.Request.QueryString.ToQueryString()); } if (pageOfAList.PageIndex > 0 || alwaysShowPreviousAndNext) { archiveData.Page = pageOfAList.PageIndex; rvd["archiveData"] = archiveData.ToString(); sb.AppendFormat("<a href=\"{1}{2}\" class=\"previous\">{0}</a>", previousText, urlHelper.RouteUrl(routeName, rvd), viewContext.HttpContext.Request.QueryString.ToQueryString()); } sb.Append("</div>"); return(sb.ToString()); }
public IPageOfList<ListenTo.Shared.DO.Action> DecorateWithActionData(IPageOfList<ListenTo.Shared.DO.Action> actions) { IActionDataHelper actionDataHelper; foreach (ListenTo.Shared.DO.Action action in actions) { actionDataHelper = ActionDataHelperFactory.CreateHelper(action); if (actionDataHelper!=null) { action.ActionData = actionDataHelper.GetActionData(action); } } return actions; }
public static string PageState <T>(this HtmlHelper htmlHelper, IPageOfList <T> pageOfAList, Func <string, string, string> localize) { if (pageOfAList.TotalPageCount > 1) { return(string.Format( "<div class=\"pageState\">{0}</div>", string.Format( localize("PageStateFormat", "{0}-{1} of {2}"), (pageOfAList.PageIndex * pageOfAList.PageSize) + 1, (pageOfAList.PageIndex * pageOfAList.PageSize) + pageOfAList.Count, pageOfAList.TotalItemCount ) )); } return(""); }
public static MvcHtmlString Ths <TModel>(this HtmlHelper <TModel> htmlHelper, IEnumerable collection, Type itemType) { var helper = EcardContext.Container.Resolve <SecurityHelper>(); User currentUser = helper.GetCurrentUser().CurrentUser; IPageOfList pagedList = null; pagedList = collection as IPageOfList; var buffer = new StringBuilder(); foreach ( PropertyDescriptor propertyDescriptor in ViewModelDescriptor.GetTypeDescriptor(itemType).Properties.Where(x => x.Permission.Check(currentUser) && x.Show).OrderBy(x => x.Order)) { buffer.Append(htmlHelper.Th(propertyDescriptor, pagedList).ToHtmlString()); } return(MvcHtmlString.Create(buffer.ToString())); }
public void OnActionExecuted(ActionExecutedContext filterContext) { object model = filterContext.Controller.ViewData.Model; IItemList itemlist = model as IItemList; if (itemlist != null) { IPageOfList pagedList = itemlist.Items as IPageOfList; if (pagedList != null) { pagedList.PageIndex = 1; pagedList.PageSize = int.MaxValue; filterContext.Result = new ExcelResult(itemlist.Items, pagedList.GetType().GetGenericArguments()[0], _securityHelper); } } EcardModelReportRequest report = model as EcardModelReportRequest; if (report != null) { report.PageIndex = 1; report.PageSize = int.MaxValue; filterContext.Result = new ExcelTableResult(report.Table); } }
public static string PostArchiveListPager <T>(this HtmlHelper htmlHelper, IPageOfList <T> pageOfAList, Func <string, string, string> localize, object values, string previousText, string nextText, bool alwaysShowPreviousAndNext) { return(SimpleArchivePager(htmlHelper, pageOfAList, "PostsByArchive", values, previousText, nextText, alwaysShowPreviousAndNext)); }
public static string PostArchiveListPager <T>(this HtmlHelper htmlHelper, IPageOfList <T> pageOfAList, Func <string, string, string> localize) { return(PostArchiveListPager(htmlHelper, pageOfAList, localize, null, localize("NewerPager", "« Newer"), localize("OlderPager", "Older »"), false)); }
public static string PostListByTagPager <T>(this HtmlHelper htmlHelper, IPageOfList <T> pageOfAList, Func <string, string, string> localize, string tagName) { return(PostListByTagPager(htmlHelper, pageOfAList, localize, new { tagName }, localize("NewerPager", "« Newer"), localize("OlderPager", "Older »"), false)); }
public static MvcHtmlString UlPaging(this HtmlHelper helper, IPageOfList list) { StringBuilder sb = new StringBuilder(); if (list == null) { return(new MvcHtmlString(sb.ToString())); } sb.AppendLine("<div class=\"fenye\">" + string.Format("<span>共{0}筆記錄,每頁{1}條 </span>", list.RecordTotal, list.PageSize)); RouteValueDictionary route = new RouteValueDictionary(); foreach (var key in helper.ViewContext.RouteData.Values.Keys) { route[key] = helper.ViewContext.RouteData.Values[key]; } foreach (string key in helper.ViewContext.RequestContext.HttpContext.Request.QueryString) { route[key] = helper.ViewContext.HttpContext.Request.QueryString[key]; } if (list.PageIndex <= 0) { sb.AppendLine("<a class=\"backpage\" href=\"javascript:void(0);\">上一頁</a>"); } else { route["pageIndex"] = list.PageIndex - 1; sb.AppendLine(helper.ActionLink("上一頁", route["action"].ToString(), route).ToHtmlString()); } if (list.PageIndex > 3) { route["pageIndex"] = 0; sb.AppendLine(helper.ActionLink(@"<b>l</b>", route["action"].ToString(), route) .ToHtmlString().Replace("<", "<").Replace(">", ">")); if (list.PageIndex >= 5) { sb.AppendLine("<a href='#'>..</a>"); } } for (int i = list.PageIndex - 2; i <= list.PageIndex; i++) { if (i < 1) { continue; } route["pageIndex"] = i - 1; sb.Append(helper.ActionLink(@"<b>" + i.ToString() + @"</b>", route["action"].ToString(), route).ToHtmlString().Replace("<", "<").Replace(">", ">")); } sb.Append(@"<a class='active' href='#'><b>" + (list.PageIndex + 1) + @"</b></a>"); for (var i = list.PageIndex + 2; i <= list.PageIndex + 4; i++) { if (i > list.PageTotal) { continue; } route["pageIndex"] = i - 1; sb.Append(helper.ActionLink(@"<b>" + i.ToString() + @"</b>", route["action"].ToString(), route).ToHtmlString().Replace("<", "<").Replace(">", ">")); } if (list.PageIndex < list.PageTotal - 4) { if (list.PageIndex <= list.PageTotal - 6) { sb.AppendLine("<a href='#'>..</a>"); } route["pageIndex"] = list.PageTotal - 1; sb.Append(helper.ActionLink(@"<b>" + list.PageTotal.ToString() + @"</b>", route["action"].ToString(), route).ToHtmlString().Replace("<", "<").Replace(">", ">")); } if (list.PageIndex < list.PageTotal - 1) { route["pageIndex"] = list.PageIndex + 1; sb.AppendLine(helper.ActionLink("下一頁", route["action"].ToString(), route).ToHtmlString()); } else { sb.AppendLine("<a class=\"nextpage\" href=\"javascript:void(0);\">下一頁</a>"); } sb.AppendLine("</div>"); return(new MvcHtmlString(sb.ToString())); }
private static MvcHtmlString Th <TModel>(this HtmlHelper <TModel> htmlHelper, PropertyDescriptor property, IPageOfList pagedList, object htmlAttributes = null, bool defaultSort = false) { var th = new ThModel { Text = property.ShortName, }; if (pagedList != null && !string.IsNullOrEmpty(property.Sort)) { if (pagedList.OrderBy == property.Sort) { th.Sort = property.Sort + " desc"; th.Directory = false; } else if (pagedList.OrderBy.StartsWith(property.Sort)) { th.Sort = property.Sort; th.Directory = true; } else { th.Sort = property.Sort; } } return(htmlHelper.Partial(GetTemplateName("th"), th, ToViewData(htmlAttributes))); }
public static MvcHtmlString Pager <TModel>(this HtmlHelper <TModel> htmlHelper, IPageOfList pageOfList) where TModel : EcardModelReportRequest { return(htmlHelper.Partial(GetTemplateName("pager"), pageOfList)); }