将选定的单选按钮文本设为粗体 (UI5)

Make Selected Radio Button Text Bold (UI5)

我在 UI5 中使用 RadioButton Group,我的要求是将选中的单选按钮设为文本 'Bold'。 这可以通过 css 或 Formatter 来实现吗? 谢谢

.......代码片段......

"": {
    "prefix": "",
    "body": [
        "RadioButtonGroup buttons=\"{oModelSummary>/QuestionSet}\" selectedIndex=\"{oModelSumnary>selectedIn}\" select=\"onSelectRb\" enabled=\"false\">",
        "<buttons>",
        "<RadioButton text=\"{oModelSummary>Name}, formatter:'MyformatterPath'\"/>",
        "</buttons>",
        "</RadioButtonGroup>"
    ],
    "description": ""
}

向单选按钮组添加 select 事件侦听器,向 selected 控件添加 css class:

onSelectRadioButtonGroupOption: function (oEvent) {
    var aRadioButtons = oEvent.getSource().getButtons();
    // Remove bold from all radiobuttons
    aRadioButtons.forEach(function (oButton) {
        oButton.removeStyleClass("your-bold-css-class");
    });
    // Add bold class to selected radiobutton
    var nSelectedIndex = oEvent.getParameter("selectedIndex");
    aRadioButtons[nSelectedIndex].addStyleClass("your-bold-css-class")
}