0
votes

i have this View:

<OverflowToolbar id="sceneToolbar" content="{path: '/scenes/scenes'}">
        <ToolbarSpcaer/>
        <ToggleButton text="{name}" custom:id="{id}" press="onSceneButtonPress"/>
        <ToolbarSpcaer/>
        <OverflowToolbarButton type="Transparent" text="Konfigurieren" icon="sap-icon://action-settings" press="onSettingsButtonPress"/>
</OverflowToolbar>

You see, I want to generate X ToggleButtons BUT I also want at the end a ToolbarSpacer and a OverflowToolbarButton and in the beginning a ToolbarSpacer.

If I delete the "static controls" it works fine. But with the "static controls" it doesn't. I don't know why...

1
Could not make out anything from question.. - Rayon
Its a aggregation binding, this you can see by the content="{path: ..." and the text="{name}". So this control will be shown repeated X times. X is the count of elements in the model. without the remaining controls (toolbarspacer and overflowtoolbarbutton) it works fine. but with, it doesn't work. - D. Schöneborn

1 Answers

1
votes

SInce the OverflowToolbar has a aggregation which holds an array of sap.ui.core.Control objects, why not simply do:

<OverflowToolbar id="sceneToolbar">
    <ToolbarSpacer/>
    <HBox items="{/scenes/scenes}">
        <ToggleButton text="{name}" custom:id="{id}" press="onSceneButtonPress"/>
    </HBox>
    <ToolbarSpacer/>
    <OverflowToolbarButton type="Transparent" text="Konfigurieren" icon="sap-icon://action-settings" press="onSettingsButtonPress"/>
</OverflowToolbar>

NB1: You may need to adapt your styling, depending on the HBox style, but key to this solution is to encapsulate your aggregated control in a container

NB2: You had a typo in ToolbarSpacer