TechAffinate
TechAffinate

Reputation: 81

Changing the bindings of a Table by clicking on a button

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?

Upvotes: 0

Views: 45

Answers (1)

jpenninkhof
jpenninkhof

Reputation: 1920

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.

Upvotes: 1

Related Questions