I would like to display a sap.m.Button in case the value of two model properties are equal. It that possible via expression binding.
Bindings:
{user-management>/alias}
"TESTUSER"{recipe-service>Author/alias}
"TESTUSER"My attempts:
<Button xmlns="sap.m" visible="{= ${user-management>/alias} === ${recipe-service>Author/alias}}" />
<!-- or: -->
<Button xmlns="sap.m" visible="{= ${user-management>/alias} === ${recipe-service>Author/alias} ? true : false}"/>
The above attempts are not working resulting with the following console error:
FormatException in property 'visible' of 'Element sap.m.Button#__button1': TESTUSER is not a valid boolean value Hint: single properties referenced in composite bindings and within binding expressions are automatically converted into the type of the bound control property, unless a different 'targetType' is specified. targetType:'any' may avoid the conversion and lead to the expected behavior.
I am not aware of using targetType for expression binding.
You must be using an OData V4 service. In that case, replace $ with % within the expression binding where the V4 OData model value is embedded but causes the above error.
Assuming the latter "recipe-service" model is sap.ui.model.odata.v4.ODataModel:
<Button xmlns="sap.m" visible="{= ${user-management>/alias} === %{recipe-service>Author/alias}}" />
See also the information about the automatic type determination in topics Changes Compared to OData V2 Model and Type Determination.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With