You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If assignee is null, I want to output group name, otherwise I want to output the assignee name. This seems to work OK in a vacuum. I have some other objects I am adding into the data binding via SmartObjects. When I use both the choose formatter and also try to reference a property from one of the other objects, it will not be able to find that property. Example:
var ctx = new { someOtherProp = "Hello" };
Smart.Format("{Assignee:choose(null): {Group.Name}|{Assignee.Name}} - {someOtherProp}", new SmartObject(new object[] {data, ctx}));
In this example, the output will fail. Could not evaluate the selector "someOtherProp"
When debugging, it seems that after the choose template is processed, the FormattingInfo.CurrentValue loses the reference to the SmartObject, and instead is just set to the data single object. This causes the next token reference to {someOtherProp} to fail, since the object it will search in is no longer the SmartObject.
Is there a better way to do a conditional format like this? For now to work around this I am just going to update my DTO with the 'conditional' property via a getter, but I'd rather not have to do that.
The text was updated successfully, but these errors were encountered:
Am I doing something wrong here? I am trying to conditionally display a property based on another property being null.
Example object (just json, but imagine this being a c# DTO):
template string:
{Assignee:choose(null): {Group.Name}|{Assignee.Name}}
If assignee is null, I want to output group name, otherwise I want to output the assignee name. This seems to work OK in a vacuum. I have some other objects I am adding into the data binding via
SmartObjects
. When I use both the choose formatter and also try to reference a property from one of the other objects, it will not be able to find that property. Example:In this example, the output will fail.
Could not evaluate the selector "someOtherProp"
When debugging, it seems that after the
choose
template is processed, theFormattingInfo.CurrentValue
loses the reference to the SmartObject, and instead is just set to thedata
single object. This causes the next token reference to{someOtherProp}
to fail, since the object it will search in is no longer the SmartObject.Is there a better way to do a conditional format like this? For now to work around this I am just going to update my DTO with the 'conditional' property via a getter, but I'd rather not have to do that.
The text was updated successfully, but these errors were encountered: