4
Axiom Script for Displaying a "-" instead of "Undefined"
Forum / Axiom Showcase
If using an asset-based grid, a value box will display "Undefined" for any asset instance that does not have the corresponding tag. The following script can be used to convert "Undefined" to "-".
public void ValueBox_OnBeginValueChange(object sender, TagSubscriptionArgs subscription, TVQ tvq)
{
// NOTE: must stop propagation of "ValueFormat" to siblings, otherwise
// the good value changes will reset siblings when they change.
// NOTE: any changes to tvq when the IsDefined flag is false will not take
// affect
// NOTE: tvq is sometimes null, so we need to account for that
// NOTE: cannot set control "Value" property to a new tvq while we are in
// a value change callback or a recursive loop will happen, so axiom
// prevents that property from being changed in this callback
// NOTE: "Text" property is used by the server and has no affect when changed
// by scripting
string valueFormat = (tvq?.IsDefined == false) ? "-" : "{Value:N2}";
ControlBase.SetProperty(
sender,
propertyName: "ValueFormat",
propertyValue: valueFormat,
updateBehavior: UpdateBehavior.NonPropagating);
}