【问题标题】:SAPUI5 Aggregation Binding with Static ControlSAPUI5 聚合绑定与静态控制
【发布时间】:2016-03-23 12:20:58
【问题描述】:

我有这个观点:

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

你看,我想生成 X ToggleButtons 但我还想要最后一个 ToolbarSpacer 和一个 OverflowToolbarButton 以及一开始的 ToolbarSpacer。

如果我删除“静态控件”,它可以正常工作。但是对于“静态控制”,它不会。不知道为什么……

【问题讨论】:

  • 无法从问题中找出任何东西..
  • 它是一个聚合绑定,你可以通过 content="{path: ..." 和 text="{name}" 看到。所以这个控件将重复显示 X 次。 X 是模型中元素的数量。没有剩余的控件(toolbarspacer 和overflowtoolbarbutton)它工作正常。但是,它不起作用。

标签: javascript data-binding sapui5


【解决方案1】:

既然OverflowToolbar 有一个包含sap.ui.core.Control 对象数组的聚合,为什么不简单地这样做:

<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:您可能需要根据 HBox 样式调整样式,但此解决方案的关键是将您的聚合控件封装在容器中

NB2:您在ToolbarSpacer 中有错字

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多