Sapui5 如何在sap.m.TileContent的内容中添加多个控件?
下面的代码对于sap.m.TileContent内的单个控件运行良好Sapui5 如何在sap.m.TileContent的内容中添加多个控件?,sapui5,Sapui5,下面的代码对于sap.m.TileContent内的单个控件运行良好 var oTile = new sap.m.GenericTile({ header: oData.results[i].Name, subheader: oData.results[i].ModuleName, size: "Auto",
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.TileContent中的sap.m.Label如下所示
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"})]
})]
})
这给了我一个错误,因为“试图将控件数组添加到单个聚合中”(内容中的单个控件工作正常,即标签或数字内容)
我正在寻找除“内容”之外的任何其他替代方法来添加多个控件,或者在内容中添加多个控件而不开发自定义控件的任何方法。如何解决这个问题
PS:我想将sap.m.RatingIndicator添加到互动程序中,以便实现喜爱的功能。发生这种情况是因为中的内容的基数为0..1,其中0是最小基数,1是最大基数。这意味着您只能在content属性中有一个项目 在以下步骤中,只能在窗体、表或对话框中使用此元素。尽管如此,如果您像这样将其插入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中的页脚和/或单位属性,就像上面的示例一样
编辑:
您可以通过在sap.m.TileContent中插入一个元素并在其中插入多个元素来解决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>
希望有帮助 发生这种情况是因为中的内容的基数为0..1,其中0是最小基数,1是最大基数。这意味着您只能在content属性中有一个项目 在以下步骤中,只能在窗体、表或对话框中使用此元素。尽管如此,如果您像这样将其插入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中的页脚和/或单位属性,就像上面的示例一样
编辑:
您可以通过在sap.m.TileContent中插入一个元素并在其中插入多个元素来解决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>
希望有帮助