Sapui5 单选按钮组:获取所选单选按钮的文本
我的视图中有sap.m.RadioButton组: 在我的控制器中: 更改区域:函数E{ console.loge.getParameterselectedIndex; },Sapui5 单选按钮组:获取所选单选按钮的文本,sapui5,Sapui5,我的视图中有sap.m.RadioButton组: 在我的控制器中: 更改区域:函数E{ console.loge.getParameterselectedIndex; }, 我可以访问所选单选按钮的索引。有没有办法获取所选单选按钮的文本?这绝对是可能的。您已经有了索引,现在您只需要RadioButton集合并选择带有相应索引的radionbutton。一旦你有了那个单选按钮,你就可以阅读它的文本了 这是如何做到的: var idx = e.getParameter("selectedIndex
我可以访问所选单选按钮的索引。有没有办法获取所选单选按钮的文本?这绝对是可能的。您已经有了索引,现在您只需要RadioButton集合并选择带有相应索引的radionbutton。一旦你有了那个单选按钮,你就可以阅读它的文本了 这是如何做到的:
var idx = e.getParameter("selectedIndex");
var button = e.getSource().getButtons()[idx];
var txt = button.getText();
简言之:
var txt = e.getSource().getButtons()[e.getParameter("selectedIndex")].getText()
您可以查看它的运行情况这绝对是可能的。您已经有了索引,现在您只需要RadioButton集合并选择带有相应索引的radionbutton。一旦你有了那个单选按钮,你就可以阅读它的文本了 这是如何做到的:
var idx = e.getParameter("selectedIndex");
var button = e.getSource().getButtons()[idx];
var txt = button.getText();
简言之:
var txt = e.getSource().getButtons()[e.getParameter("selectedIndex")].getText()
您可以查看它的运行情况我想我找到了一个不同的选项来阅读所选单选按钮文本。。只要有人需要它 您需要为单选按钮组设置一个Id,例如:
<m:RadioButtonGroup id='radioButtonGroup' valueState="" select="changeRegion()">
<m:buttons>
<m:RadioButton id="rb-S" text="S"/>
<m:RadioButton id="rb-MW" text="MW"/>
<m:RadioButton id="rb-NE" text="NE"/>
<m:RadioButton id="rb-W" text="W"/>
</m:buttons>
我想我找到了一个不同的选项来阅读选中的单选按钮文本。。只要有人需要它 您需要为单选按钮组设置一个Id,例如:
<m:RadioButtonGroup id='radioButtonGroup' valueState="" select="changeRegion()">
<m:buttons>
<m:RadioButton id="rb-S" text="S"/>
<m:RadioButton id="rb-MW" text="MW"/>
<m:RadioButton id="rb-NE" text="NE"/>
<m:RadioButton id="rb-W" text="W"/>
</m:buttons>
最简单的方法是:
e.getSource().getSelectedButton().getText();
最简单的方法是:
e.getSource().getSelectedButton().getText();
最近学习了sap.ui.getCore.byIdthis.createIdradioButtonGroup的替代方案,即this.getView.byIdradioButtonGroup。我读到不建议使用sap.ui.getCore最近学习了sap.ui.getCore.byIdthis.createIdradioButtonGroup的替代品,即this.getView.byIdradioButtonGroup。我已经了解到不建议使用sap.ui.getCore