xpages 复选框单值选择 [英] xpages checkbox single value selection
本文介绍了xpages 复选框单值选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用户是否可以从
中只选择一个值?换句话说,checkBoxGroup 像单选按钮一样工作吗?
Is it possible the users to select only one value from a <xp:checkBoxGroup>
? In other words, the checkBoxGroup to work like a radioButton?
我知道我可以轻松地将控件更改为单选按钮,但我只是好奇.
I know I could easily change the control to a radioButton but I was just curios.
推荐答案
您可以使用以下代码来使用具有单个选择的复选框组.该代码并不完美,因为您需要单击两次才能激活一个新复选框.
You can use the following code to use a checkboxgroup with a single selection. The code is not perfect, because you need two clicks to activate a new checkbox.
<xp:checkBoxGroup id="checkBoxGroup1">
<xp:selectItem itemLabel="first" itemValue="1"></xp:selectItem>
<xp:selectItem itemLabel="second" itemValue="2"></xp:selectItem>
<xp:selectItem itemLabel="third" itemValue="3"></xp:selectItem>
<xp:selectItem itemLabel="fourth" itemValue="4"></xp:selectItem>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="checkBoxGroup1">
<xp:this.action>
<![CDATA[#{javascript:var checkedValues = getComponent("checkBoxGroup1").getAttributes().get("value")
varArray = new Array(0)
varArray[0] = checkedValues.length < 2 ? checkedValues[0] : undefined
getComponent("checkBoxGroup1").getAttributes().put("value", varArray);
}]]>
</xp:this.action></xp:eventHandler></xp:checkBoxGroup>
这篇关于xpages 复选框单值选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文