Changing the bindings of a Table by clicking on a button

杀马特。学长 韩版系。学妹 提交于 2020-01-06 20:04:08

问题


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>

is there any possibility I can change that?


回答1:


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.

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} }

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



来源:https://stackoverflow.com/questions/38053191/changing-the-bindings-of-a-table-by-clicking-on-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!