我有一个观点..
<mvc:View controllerName="quiz.controller.View1"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
displayBlock="true"
>
<App>
<Page title="{i18n>title}">
<Text text="{questions>/question/text}" />
<RadioButtonGroup columns="5">
<RadioButton id="RB3-1" text="{questions>/question/option/1}" />
<RadioButton id="RB3-2" text="{questions>/question/option/2}" />
<RadioButton id="RB3-3" text="{questions>/question/option/3}" />
<RadioButton id="RB3-4" text="{questions>/question/option/4}" />
</RadioButtonGroup>
<Button text="Default" press=".onPress" />
</Page>
</App>
</mvc:View>
..其中有一个带有四个选项的单选按钮组。按下按钮时,我希望显示一个单选按钮。
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast"
], function(Controller, MessageToast) {
"use strict";
return Controller.extend("quiz.controller.View1", {
onPress: function(evt) {
// MessageToast.show(); over here I want to show the button which is pressed
}
});
});
我该怎么办?我尝试使用document.getElementById()
,但它不能在这里工作。
答案 0 :(得分:2)
你需要给id:
<RadioButtonGroup id="IDRadioButtonGroup"
并使用按钮方法访问它:
onPress: function(){
var oIDRadioButtonGroup = this.byId("IDRadioButtonGroup");
console.log("BUTTON: " + oIDRadioButtonGroup.getSelectedButton());
}