cancel
Showing results for 
Search instead for 
Did you mean: 

sap.ui.Table Binding a value to column titles

0 Kudos
448

I am trying to bind a value to a column titles in XML view similar to binding data to actual data cells as following (this works):

<Column width="7em" 
   sortProperty="col1"
   filterProperty="col1">
   <m:Label text="Year" />
      <template>
         <m:Text text="{col1}"/>
      </template>
</Column>

(This does not work)--> If I try to bind data to column title, only first string literal "Year" shows up, but not the data in binding expression:

<Column width="7em" 
   sortProperty="col1"
   filterProperty="col1">
   <m:Label text="Year {=${year}}"/>
      <template>
         <m:Text text="{col1}"/>
      </template>
</Column>

The goal is to have a concatenated string such as: "Year" + currentYear as a column title. The only way (from what I understand) to have currentYear in XML view is to bind it through expression binding. Is there any ideas how to overcome this issue? Thank you!

View Entire Topic
maheshpalavalli
Active Contributor
0 Kudos

Hi Sergey Koch,

You do not need to do an expression binding there, even if you do it will not cause any issue.. It should work ideally and worked for me as well.

Simply giving {year} also should work.

But your actual issue might be completely different.(Assumption)

 <m:Label text="Year {=${year}}"/> // Why are you mentioning the year here??? is it part of your rows binding?
      <template>
         <m:Text text="{col1}"/>
      </template>

you are mentioning "year" property in the label, where is that year coming coming from? is it the same property which is available in your rows binding?? If yes, it will not work.. because whatever the model and its array property name you mentioned in the rows binding, it will only apply the binding to the template(which are rows, in your case {col1} will work)..

So if you create a model separately and then bind one of the property to the label, it works very well but it wont when we try to use the property of the rows binding.

BR,

Mahesh

0 Kudos

Yes, I was using the same model with a property of the rows binding to bind it to the label. No I see what my problem was. Thanks!