如何在sap.m.TileContent的内容里面添加多个控件?

How to add multiple control inside the content of sap.m.TileContent?

下面的代码对于 sap.m.TileContent

中的单个控件工作正常
var oTile = new sap.m.GenericTile({
                            header: oData.results[i].Name,
                            subheader: oData.results[i].ModuleName,
                            size: "Auto",
                            frameType: "OneByOne",
                            press: [that.handleTilePress, that],
                            tileContent: [new sap.m.TileContent({
                                size: "Auto",
                                footer: oData.results[i].Num.toLocaleString() + " views",
                                content: [new sap.m.NumericContent({
                                    size: "Auto",
                                    nullifyValue: false,
                                    icon: "sap-icon://"+oData.results[i].tileIcon
                                })]
                            })]
                        });

但是当我尝试向 sap.m.TileContent 添加一个控件时,假设 sap.m.Label 在 sap.m.TileContent 中,如下所示,

var oTile = new sap.m.GenericTile({
                            header: oData.results[i].Name,
                            subheader: oData.results[i].ModuleName,
                            size: "Auto",
                            frameType: "OneByOne",
                            press: [that.handleTilePress, that],
                            tileContent: [new sap.m.TileContent({
                                size: "Auto",
                                footer: oData.results[i].Num.toLocaleString() + " views",
                                content: [new sap.m.NumericContent({
                                    size: "Auto",
                                    nullifyValue: false,
                                    icon: "sap-icon://"+oData.results[i].tileIcon
                                }),
                            new sap.m.Label({text:"dummyText"})]
                            })]
                        })

它给我一个错误“试图将一组控件添加到单个聚合”(内容中的单个控件工作正常,即标签或数字内容)

我正在寻找除 'content' 之外的任何其他替代方法来添加多个控件,或者在不开发自定义控件的情况下以任何方式在内容中添加多个控件。如何解决?

PS:我想将 sap.m.RatingIndicator 添加到磁贴中,以便我可以实现最喜欢的功能。

发生这种情况是因为 sap.m.TileContent aggregations 中的内容的基数为 0..1,其中 0 是最小基数,1 是最大基数。这意味着内容 属性.

中只能有一个项目

根据 Fiori Design Guidelines for Rating Indicator,您应该只在表单、表格或对话框中使用此元素。话虽如此,如果你像这样将它插入 sap.m.TileContent,它仍然可以工作:

<GenericTile header="Cumulative Totals" subheader="Expenses">
   <TileContent unit="Unit" footer="Footer Text">
      <content>
         <RatingIndicator id="RI_default" maxValue="5" value="4" tooltip="Rating Tooltip"/>
      </content><!-- sap.ui.core.Control -->
   </TileContent>
</GenericTile>

如果您想在磁贴中添加其他文本,我建议您使用 sap.m.TileContent 中的页脚 and/or 单元属性,就像我上面的示例一样。

编辑:

您可以通过在 sap.m.TileContent 中插入一个 sap.m.VBox 元素并在其中插入多个元素来解决 sap.m.TileContent 聚合的基数,尽管 我真的会建议您不要这样做!

示例:

<GenericTile header="Cumulative Totals" subheader="Expenses">
   <TileContent unit="Unit" footer="Footer Text">
      <content>
         <VBox>
             <RatingIndicator id="RI_default" maxValue="5" value="4"/>
             <Label text="Dummy"/>
         </VBox>
      </content>
   </TileContent>
</GenericTile>

希望对您有所帮助!