如何显示基于某些值的特定控件?

时间:2018-06-29 19:42:21

标签: sapui5

我有以下代码:

<t:template>
  <Text text="{path: 'dateday', formatter:'.formatdate'}"/>
</t:template>

<t:template>
  <Text text="{path: 'datetime', formatter:'.formatime'}"/>
</t:template>

仅当'dateday'值为nullundefined或为空时,才需要显示第二个模板。

有什么想法可以用XML实现吗?

2 个答案:

答案 0 :(得分:1)

可以通过属性visible(或setVisible)显示或隐藏所有控件。 将其与expression binding结合使用,并且仅当dateday值为 falsy时第二个文本才可见。

<Text
  text="{
    path: 'datetime',
    formatter:'.formatime'
  }"
  visible="{= !!${dateday}}"
/>

答案 1 :(得分:0)

好的,所以我用'visible'属性弄清楚了

<t:template visible="{= ${/dateday} !== null }">
<Text text="{path: 'dateday', formatter:'.formatday'}"/>
</t:template>

<t:template visible="{= ${/dateday} === null }">
<Text text="{path: 'datetime', formatter:'.formatime'}"/>
</t:template>

希望它可以帮助其他人:P

相关问题