Search code examples
sapui5

Conditional column value in UI5 table


I have a column in table whose value is bound to a property of data model. text = { modelName>/OrderNo}. How to make it conditional based on a flag? If property from Model isReturnable = true, I want to show text = {modelName>/ReturnNo} else I want to show {OrderNo}. How to built syntax for that?

<table:Column>
<Label class="smartist-table-column-header" text="Qty Returned"/>
<table:template>
<Text text="{ path: 'OrderDetail>OrderNo'}"/>
</table:template>
</table:Column>  

Solution

  • You can use expression binding. See URL for details: https://ui5.sap.com/#/topic/daf6852a04b44d118963968a1239d2c0

    Solution to your problem:

    <Text text="{= ${modelName>isReturnable} ? ${modelName>/ReturnNo} : ${OrderDetail>OrderNo}}" />