4
![](https://s3-us-west-2.amazonaws.com/media.forumbee.com/avatar/a73c9b027b2a0b1d2e708387b872d9f9-1623159123300/h/40.jpg)
Forum / Axiom Showcase
Axiom Script for Displaying a "-" instead of "Undefined"
![](https://s3-us-west-2.amazonaws.com/media.forumbee.com/i/0dba2936-7a0c-4f27-8ef9-7cee26fb8235/h/547.png)
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);
}
Like
Follow
4
Reply