Skip to Content

Dynamic template sap.ui.table.Column

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.

Add a comment
10|10000 characters needed characters exceeded

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

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.