我需要为单选按钮组中的每个单选按钮显示一个图像。
我已经看到了一些自定义单选按钮和单选按钮组的示例,但它们都没有工作。
有人可以指出我正确的方向吗?
答案 0 :(得分:2)
“正确的方向”是首先了解哪些替代品可以帮助用户实现他们的目标(而不是创建自定义控件并维护它)。 例如:我们可以轻松模仿可以使用以下组合显示图像的单选按钮的行为:
sap.m.List具有以下属性:
mode="SingleSelectLeft"
includeItemInSelection="true"
backgroundDesign="Transparent"
showSeparators="None"
width="auto"
支持显示图像的ListItemBase子类(例如sap.m.StandardListItem
[1] 或.CustomListItem
)。
运行示例以查看其实际操作:
sap.ui.getCore().attachInit(() => sap.ui.require([
"sap/ui/core/mvc/XMLView",
"sap/ui/model/json/JSONModel",
], (XMLView, JSONModel) => XMLView.create({
definition: `<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
height="100%"
displayBlock="true"
>
<App>
<List
mode="SingleSelectLeft"
backgroundDesign="Transparent"
showSeparators="None"
width="auto"
includeItemInSelection="true"
items="{options>/}"
>
<StandardListItem
icon="{options>img}"
title="{options>text}"
/>
</List>
</App>
</mvc:View>`,
models: {
"options": new JSONModel([
{
text: "Option 1",
img: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNTAwIDUwMCI+PGRlZnM+PGNsaXBQYXRoIGlkPSJhIj48cGF0aCBkPSJNMjQ0LjQ0NjQ1LDBzLS4wNTIxNiwyMC44MDk3LDU0LjM0NTYyLDUzLjg1ODgyQzQwNC40MDkyNywxMTguMDI2MDcsNDA0LjA1MzI5LDE3Ni44NTI4OSw0MDQuMDUzMjksMTg5LjE5OGMwLDUyLjQ0MDc2LTU0LjU4LDg2LjM0MDU5LTc5LjkwNDY4LDU4LjkwMzU4LDAsMCwyNC44NDkwNS0xOC40NDE4NCwyNC44ND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4LDc3LjYxNDIyLDEyNS4yNjUwNSwzNy41NTYyMiwxODQuNTA3NDljLTM1Ljk4MDksNTMuMjEyNzQtMjQuMjk5MDgsMTIzLjU5NzMzLTE3LjgyMTg2LDE0NS4yNDgsMjkuMzc1LDk4LjE4ODY4LDEyMC40MDUyOCwxNjkuNzUzMjgsMjI4LjE1MDE3LDE2OS43NTMyOCwxMzEuNTAyOTMsMCwyMzkuNDc3ODktMTA1LjIzMzE5LDIzOS40Nzc4OS0yMzYuNzM1ODlDNDg3LjM2MjQzLDYzLjY5MDg5LDI5OC4wOTgyLDQyLjU2NjI5LDI0NC40NDY0NS0uNDkxMjVaIiBmaWxsPSJ1cmwoI2IpIiBzdHlsZT0ibWl4LWJsZW5kLW1vZGU6b3ZlcmxheSIvPjwvZz48L2c+PC9zdmc+",
},
{
text: "Option 3",
img: "sap-icon://sap-ui5",
},
])
}
}).then(view => view.placeAt("content"))));
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core, sap.m"
data-sap-ui-theme="sap_belize"
data-sap-ui-async="true"
data-sap-ui-compatversion="edge"
data-sap-ui-xx-waitfortheme="true"
></script><body id="content" class="sapUiBody" style="height: 100%;"></body>
[1]:如果是sap.m.StandardListItem
,请注意它只支持quadrat比例的图像。 src 不同比例的图像将显示不正确
答案 1 :(得分:2)
我实现了图像单选按钮选项:
因此,有两个容器:一个用于整体收容,另一个用于放射性按钮/图像对齐。
<强>结果:强>
<强>代码:强>
数据:
var data = {
answers: [
{
AnswerLabel: "Excellent",
SmileyUrl :"./images/satisfied.jpg"
},
{
AnswerLabel: "Good",
SmileyUrl :"./images/good.jpg"
},
{
AnswerLabel: "Neutal",
SmileyUrl :"./images/neutral.jpg"
},
{
AnswerLabel: "Poor",
SmileyUrl :"./images/bad.jpg"
},
{
AnswerLabel: "Horrible",
SmileyUrl :"./images/horrible.jpg"
}
]
};
var model = new sap.ui.model.json.JSONModel(data);
this.getView().setModel(model, "view");
查看:
RadioButton上面的图片:
<HBox items="{view>/answers}"
justifyContent="SpaceAround"
class='sapUiMediumMarginTop'> <!-- This is Parent Container -->
<VBox alignItems='Center'> <!-- Alignment of radioButton and image. Change to VBox/HBox for vertical/horizontal alignment -->
<items>
<Image
src="{view>SmileyUrl}"
width="3rem"/> <!-- Image to be displayed -->
<RadioButton
groupName='answers'
text="{view>AnswerLabel}" />
</items>
</HBox>
</VBox>
图像旁边的radiobutton
<HBox items="{view>/answers}"
justifyContent="SpaceAround"
class='sapUiMediumMarginTop'> <!-- This is Parent Container -->
<HBox alignItems='Center'> <!-- Alignment of radioButton and image. Change to VBox/HBox for vertical/horizontal alignment -->
<items>
<Image
src="{view>SmileyUrl}"
width="3rem"/> <!-- Image to be displayed -->
<RadioButton
groupName='answers'
text="{view>AnswerLabel}" />
</items>
</HBox>
</HBox>
如果您需要更多解释和信息,请与我们联系。