通过单击按钮更改表的绑定

通过单击按钮更改表的绑定

本文介绍了通过单击按钮更改表的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改我现在拥有的表的绑定,例如在我有此绑定的列上:

I want to change the binding of a table I have right now, for example on a column I have this binding:

<t:Column id="orderId" hAlign="Center">
                            <Label id="labelOrderId" text="{i18n>transactionId}"/>
                            <t:template>
                                <Text text="{id}"/>
                            </t:template>
                        </t:Column>

通过按下按钮,我想将其更改为此绑定:

by Pressing a button I want to change this to this binding:

<t:Column id="orderId" hAlign="Center">
                            <Label id="labelOrderId" text="{i18n>transactionId}"/>
                            <t:template>
                                <Text text="{newTransactionId}"/>
                            </t:template>
                        </t:Column>

我有没有可能改变它?

推荐答案

如果你想解绑一个属性并将它绑定到另一个数据属性,你可以使用 unbindPropertybindProperty 方法.要了解有关如何使用这些方法的更多信息,您可以查看 这个关于属性绑定的页面.

If you want to unbind a property and bind it to another data attribute, you can use the unbindProperty and bindProperty methods. To learn more about how to use these methods, you can have a look at this page about property binding.

在您的情况下,它会导致相当多的复杂性和代码,因为您的字段嵌入在表格中,您必须先找到需要更改的表格行.

In your case, it will lead to quite some complexity and code because your field is embedded in a table, and you'll have to find the table row you need to change first.

不过,您可能需要考虑表达式绑定.从您的示例中,您似乎只想在 newTransactionId 不存在时显示旧的 id .如果是这种情况,您的表达式绑定可能如下所示:

You may want to consider expression binding though. From your example, it seems that you only want to show the old id when the newTransactionId is not present. If that's the case, your expression binding could look like this:

{= ${newTransactionId} ? ${newTransactionId} : ${id} }

要了解有关表达式绑定的更多信息,您可以查看第 22 步SAPUI5 演练中,很好地描述了表达式绑定.

To learn more about expression binding, you could have a look at Step 22 of the SAPUI5 walkthrough, which describes expression binding very well.

这篇关于通过单击按钮更改表的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 04:12