Step 22 Expression Binding

表达式绑定
https://ui5.sap.com/#/topic/c98d57347ba444c6945f596584d2db45

webapp/view/InvoiceList.view.xml

<mvc:View
controllerName="sap.ui.demo.walkthrough.controller.InvoiceList"
xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc">
   <List
      headerText="{i18n>invoiceListTitle}"
      class="sapUiResponsiveMargin"
      width="auto"
      items="{invoice>/Invoices}" >
      <items>
         <ObjectListItem
            title="{invoice>Quantity} x {invoice>ProductName}"
            number="{
		parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}],
		type: 'sap.ui.model.type.Currency',
		formatOptions: {
			showMeasure: false
		}
		}"
		numberUnit="{view>/currency}"
        	numberState="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }"/>
      </items>
   </List>
</mvc:View>

numberState="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }"
ExtendedPrice大于50,价格就是Error状态,以红色表示;反之就是Success,以绿色显示。
numberState的合法值:Error(红色),Success(绿色),Warning(橘色),Information(蓝色)。

约定:只用Expression Binding,做简单的计算逻辑,不用于复杂的。

vx:xiaoshitou5854

posted @ 2021-09-06 08:32  小石王  阅读(415)  评论(0编辑  收藏  举报