public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { string displayValue = Display.CreateObject().DisplayValue(value, field, rowValue); if (string.IsNullOrEmpty(Content)) { return(displayValue); } string linkUrl = HrefDisplayConfig.ResolveRowValue(rowValue, Content); if (string.IsNullOrEmpty(linkUrl)) { return(displayValue); } linkUrl = StringUtil.EscapeHtmlAttribute(AppUtil.ResolveUrl(linkUrl)); switch (Mode) { case DisplayMode.Normal: return(string.Format(ObjectUtil.SysCulture, "<a data-url='{0}' href='#'>{1}</a>", linkUrl, displayValue)); case DisplayMode.Dialog: string title; if (!string.IsNullOrEmpty(DialogTitle)) { title = HrefDisplayConfig.ResolveRowValue(rowValue, DialogTitle); } else { title = displayValue; } return(string.Format(ObjectUtil.SysCulture, "<a data-dialog-url='{0}' data-title='{2}' href='#'>{1}</a>", linkUrl, displayValue, title)); default: TkDebug.ThrowImpossibleCode(this); return(string.Empty); } }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue, string linkedValue) { if (rowValue == null) { return(linkedValue); } string linkUrl = HrefDisplayConfig.ResolveRowValue(rowValue, Content); if (string.IsNullOrEmpty(linkUrl)) { return(linkedValue); } else { linkUrl = AppUtil.ResolveUrl(linkUrl); } HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); if (!string.IsNullOrEmpty(Target)) { builder.Add("target", Target); } builder.Add("href", "#"); string urlName = Mode == DisplayMode.Normal ? "data-url" : "data-dialog-url"; builder.Add(urlName, linkUrl); if (Mode == DisplayMode.Dialog && !string.IsNullOrEmpty(DialogTitle)) { string title = HrefDisplayConfig.ResolveRowValue(rowValue, DialogTitle); builder.Add("data-title", title); } return(string.Format(ObjectUtil.SysCulture, "<a {0}>{1}</a>", builder.CreateAttribute(), StringUtil.EscapeHtml(linkedValue))); }