1

I have a column in a sap.ui.table.Table. In this column, I want to display my template control depending on the value. If I have a typeof DateTime, I want to use the DatePicker, typeof DateTime a DateTimePicker, and so on.

Now I want to differ it in my XMLView / Fragment but it only checks my last control (DateTimePicker):

<table:template>
  <Input id="masterDataValueInput"
    value="{thingDetail>value}"
    placeholder="{path:'thingDetail>type', formatter:'.formatter.placeHolderFormatter'}"
    visible="{= ! ${path: 'thingDetail>properties'} &amp;&amp; ${path: 'thingDetail>type', formatter: '.formatter.inputVisibility'}}"
    enabled="{appView>/isCurrentTenant}"
    type="{path:'thingDetail>type', formatter:'.formatter.inputTypeFormatter'}"
  />
  <DatePicker id="masterDataValueDate"
    value="{thingDetail>value}"
    displayFormat="short"
    visible="{= ! ${path: 'thingDetail>properties'} &amp;&amp; ${path: 'thingDetail>type', formatter: '.formatter.dateVisibility'}}"
    enabled="{appView>/isCurrentTenant}"
    change="handleChange"
  />
  <DateTimePicker id="masterDataValueDateTime"
    value="{thingDetail>value}"
    displayFormat="short"
    visible="{= ! ${path: 'thingDetail>properties'} &amp;&amp; ${path: 'thingDetail>type', formatter: '.formatter.datetimeVisibility'}}"
    enabled="{appView>/isCurrentTenant}"
    change="handleChange"
  />
</table:template>
  • So the <Input> and the <DatePicker> controls are never displayed..
  • The methods in my formatter are never called either.
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170

1 Answers1

1

The reason why only the last control (DateTimePicker) is taken into account is because the template aggregation of sap.ui.table.Column awaits only a single control (0..1).

In order to make use of all three controls, you'll have to wrap them together in another container / layout control such as HorizontalLayout:

<table:template>
  <layout:HorizontalLayout>
    <!-- your controls -->
  </layout:HorizontalLayout>
<table:template>

About the expression binding..

Try with parts:

visible="{= !${thingDetail>properties} &amp;&amp; ${parts: [{path: 'thingDetail>type'}], formatter: '.formatter.inputVisibility'}}"

If that didn't call the formatter, toss that expression binding (as it's become hard to read anyway) and go for the usual property binding with the appropriate formatter:

visible="{
  parts: [
    'thingDetail>properties',
    'thingDetail>type'
  ],
  formatter: '.formatter.myFormatter'
}"
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170