我想更改我现在拥有的表的绑定(bind),例如在我具有此绑定(bind)的列上:
<t:Column id="orderId" hAlign="Center">
<Label id="labelOrderId" text="{i18n>transactionId}"/>
<t:template>
<Text text="{id}"/>
</t:template>
</t:Column>
通过按一个按钮,我想将其更改为此绑定(bind):
<t:Column id="orderId" hAlign="Center">
<Label id="labelOrderId" text="{i18n>transactionId}"/>
<t:template>
<Text text="{newTransactionId}"/>
</t:template>
</t:Column>
我有可能改变这一点吗?
最佳答案
如果要取消绑定(bind)属性并将其绑定(bind)到另一个数据属性,可以使用 unbindProperty
和 bindProperty
方法。要了解有关如何使用这些方法的更多信息,您可以查看this page about property binding .
就您而言,这将导致相当多的复杂性和代码,因为您的字段嵌入在表中,并且您必须首先找到需要更改的表行。
不过,您可能需要考虑表达式绑定(bind)。从您的示例来看,您似乎只想在 newTransactionId
不存在时显示旧的 id
。如果是这种情况,您的表达式绑定(bind)可能如下所示:
{= ${newTransactionId} ? ${newTransactionId} : ${id} }
要了解有关表达式绑定(bind)的更多信息,您可以查看 Step 22 of the SAPUI5 walkthrough ,它很好地描述了表达式绑定(bind)。
关于javascript - 通过单击按钮更改表的绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38053191/