/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(System.Web.UI.Control parentControl, string value, System.Collections.Generic.Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { decimal?rangeValue = value.AsDecimalOrNull(); if (rangeValue == null) { return(string.Empty); } rangeValue = decimal.Round(rangeValue.Value, 0); var configurationJSON = configurationValues.GetValueOrNull(ConfigurationKey.ConfigurationJSON); List <ConditionalScaleRangeRule> conditionalScaleRangeRuleList = configurationJSON.FromJsonOrNull <List <ConditionalScaleRangeRule> >() ?? new List <ConditionalScaleRangeRule>(); var matchingRangeRule = conditionalScaleRangeRuleList.FirstOrDefault(a => (a.HighValue ?? decimal.MaxValue) >= rangeValue.Value && rangeValue.Value >= (a.LowValue ?? decimal.MinValue)); if (matchingRangeRule != null) { return($"<span class='label scale-label' style='background-color:{matchingRangeRule.Color}'>{matchingRangeRule.Label}</span>"); } else { // if out-of-range, display nothing return(string.Empty); } }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override System.Web.UI.Control EditControl(System.Collections.Generic.Dictionary <string, ConfigurationValue> configurationValues, string id) { var shouldRequireTrailingForwardSlash = configurationValues.GetValueOrNull(ConfigurationKey.ShouldRequireTrailingForwardSlash)?.AsBoolean(); return(new UrlLinkBox { ID = id, ShouldRequireTrailingForwardSlash = shouldRequireTrailingForwardSlash ?? false }); }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues"></param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(System.Web.UI.Control parentControl, string value, System.Collections.Generic.Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { var shouldAlwaysShowCondensed = configurationValues.GetValueOrNull(ConfigurationKey.ShouldAlwaysShowCondensed).AsBoolean(); if (string.IsNullOrWhiteSpace(value)) { return(string.Empty); } else { if (condensed || shouldAlwaysShowCondensed) { return(value); } else { return(string.Format("<a href='{0}'>{0}</a>", value)); } } }