0
votes

I have a view:

<List
        items="{data>/Stages}">
           <CustomListItem>
            <Panel>
                <headerToolbar>
                     <Toolbar>
                         <content>
                           <Button
                              visible="{= ${data>/Stages/length} > 1}" />
                         </content>
                     </Toolbar>
                 </headerToolbar>
                 <content>
                 <Table
                   growing="true" 
                   growingScrollToLoad="false"
                   items="{
                       path: 'data>FieldWorks',
                       templateShareable: true
                   }"
                   class="blueTable originTable techTable">
                   <columns>
                     <Column
                       visible="true"
                       vAlign="Middle" 
                       width="15px" />
                   </columns>
                   <items>
                     <ColumnListItem>
                         <cells>
                          <core:Icon
                              visible="{ ???}"
                              src="sap-icon://customfont/moving"
                              size="2.1rem"
                              color="#14c6c9" />
                         </cells>
                     </ColumnListItem>
                  </items>
               </Table>
            </content>
        </Panel>
    </CustomListItem>
</List>

I have a model (example):

data: {
   Stages: [{
       FieldWorks: [{}, ....]
    }, .....]
}

I hide my button (in my toolBar) by expression binding as you can see. What is the best way to hide my Icon (in CustomListItem) by condition FieldWorks.length > 1

2
Did you try something to get this? Or you get any error? A similar way of expression binding might help you or a formatter? - Nandan Chaturvedi
I thought about external formatter, but it doesn't seem nice to me. - Дмитрий Богданов

2 Answers

0
votes

If you are using a JSON Model just add boolean property to your JSONModel to the FieldWorks entity and bind the visible property to it. Then one time you have to set it when data is loaded or created and that's it.

0
votes

You can define a new property in your json Model under the FieldWorks property in order to bind the visibility of the icon.

you can use Object.defineProperty (SPEC MDN) to define your calculated new property.