javascript - 通过单击按钮更改表的绑定(bind)

标签 javascript sapui5

我想更改我现在拥有的表的绑定(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)到另一个数据属性,可以使用 unbindPropertybindProperty 方法。要了解有关如何使用这些方法的更多信息,您可以查看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/

相关文章:

javascript - 自定义我的对象在 JS 控制台中的显示方式

javascript - JS : Create comma separated values from values of multiple inputs

javascript - 我可以从文件中获取 javascript 函数中的 html 内容吗

javascript - 显示一个或多个元素及其已隐藏的内容

xml - 我在哪里可以找到 sapui5 中可用的所有 XML 元素的列表?

javascript - 如果值为空,则 sap.m.Text 的日期格式化程序不可见

javascript - 如何将 XML View 传输到 JavaScript View /SAPUI5

javascript - 单击下一步后保持相同的向导步骤

javascript - 从 React 页面导航到纯 HTML 页面

sapui5 - VizFrame 错误消息 : 50014 - Feed Failed Tests could not accept more data containers