Class AttributedResult
Object
AttributedResult
Provides means for output elements' formatting.
The usage is simple, instead of returning the output value, create a new AttributedResult
instance like this:
api.attributedResult(plain value)
, customize it by calling its various methods, and return it finally.
Example:
def cost = out.MarginPct
def myOptions = ["A" , "B" , "C" ]
return api.attributedResult(cost)
.withBackgroundColor(cost < 0.30 ? "red" : "#0101DF")
.withSuffix(cost < 0.30 ? "!!!" : null)
.withTextColor(cost < 0.30 ? "white" : null)
.withTextDecoration(cost < 0.30 ? "underline" : null)
.withManualOverrideValueOptions(myOptions)
-
Constructor Summary
ConstructorDescriptionAttributedResult
(Object result) AttributedResult
(Object result, Map<String, Object> attrs) -
Method Summary
Modifier and TypeMethodDescription<T> T
clearAttribute
(String name) boolean
containsAttribute
(String name) <T> T
getAttribute
(String name) In case the result element is overridable, this method clears a set (list) of values defined with above withManualOverrideValueOptions method IMPORTANT NOTE: This is implemented only for Pricelists, PriceGrids and CalculationGrids.<T> T
setAttribute
(String name, Object value) withBackgroundColor
(String cssColor) Sets the background color.In case the result element is overridable, this method defines if the selection box shows also the "empty value" option.withManualOverrideValueOptions
(List<Object> options) In case the result element is overridable, this method defines a set (list) of values that the user can pick from (vs. default free-style data entry) IMPORTANT NOTE: This is meant to list a few options only.withRawCSS
(String css) Adds any valid CSS style to the cell.withSuffix
(String suffix) Sets a suffix to be appended to the result.withTextColor
(String cssColor) Sets the text (foreground) color.withTextDecoration
(String textDecoration) Sets the decoration to be added to the resulting text.
-
Constructor Details
-
AttributedResult
-
AttributedResult
-
-
Method Details
-
getResult
-
getAttributes
-
getAttribute
-
setAttribute
-
clearAttribute
-
containsAttribute
-
withRawCSS
Adds any valid CSS style to the cell. Note: There is no check if the CSS is actually valid, the values are just passed through as-is- Parameters:
css
- The full CSS style parameter in the form of "property:value;"- See Also:
-
withSuffix
Sets a suffix to be appended to the result. -
withTextColor
Sets the text (foreground) color.- See Also:
-
withTextDecoration
Sets the decoration to be added to the resulting text.Valid options are
underline
,line-through
, andoverline
.- See Also:
-
withBackgroundColor
Sets the background color.- See Also:
-
withManualOverrideValueOptions
In case the result element is overridable, this method defines a set (list) of values that the user can pick from (vs. default free-style data entry) IMPORTANT NOTE: This is meant to list a few options only. Not a large list of choices! There is not a hard limitation here, but if this is used widely in a particular configuration and the list of options is long the browser may not be able to render it anymore and/or the data transfer speeds may suffer.- Parameters:
options
- The list of valid options in the UI- Returns:
-
removeManualOverrideValueOptions
In case the result element is overridable, this method clears a set (list) of values defined with above withManualOverrideValueOptions method IMPORTANT NOTE: This is implemented only for Pricelists, PriceGrids and CalculationGrids.- Returns:
-
withManualOverrideAllowEmpty
In case the result element is overridable, this method defines if the selection box shows also the "empty value" option. Default is true- Returns:
-