cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic template sap.ui.table.Column

former_member613696
Discoverer
0 Kudos

Hello everyone,

I'm using a sap.ui.table.Table with 2 columns to display products like this:

<Table id="myTab"
    rows="model>/ProductSet"
    title="Products">
    <columns>
      <Column width="4rem">
        <m:Label text="ProductId" />
         <template>
           <m:Label text="{model>ProductID}" visible="{model>labelFlag}"/>
           <m:Button text="{model>ProductID}" visible="{model>buttonFlag}"/>
         </template>
     </Column>

     <Column width="4rem">
       <m:Label text="Product Category" />
        <template>
          <m:Label text="{model>ProductCat}" visible="{model>labelFlag}"/>
        </template>
    </Column>
   </columns>
</Table>

I want that the ProductId will be displayed either in Button or in Label form but it does not work. I found this topic Dynamic Template in forum but I can not figure it out how can I use this in XML-View. Could someone help me please.

Thanks and regards,

T.

former_member613696
Discoverer
0 Kudos

Hello everyone,

I have solved problem myself. This code below does the trick:

<Table id="myTab"
   rows="model>/ProductSet"
   title="Products">
   <columns>
     <Column width="4rem">
       <m:Label text="ProductId" />
        <template>
          <m:VBox>
           <m:items>
              <m:Label text="{model>ProductID}" visible="{model>labelFlag}"/>
              <m:Button text="{model>ProductID}" visible="{model>buttonFlag}"/>

           </m:items>
        </m:VBox>
      </template>
    </Column>

     <Column width="4rem">
       <m:Label text="Product Category" />
        <template>
          <m:Label text="{model>ProductCat}" visible="{model>labelFlag}"/>
        </template>
    </Column>
   </columns>
</Table>

Accepted Solutions (0)

Answers (0)