Question
Pegasystems Inc.
JP
Last activity: 25 Jun 2020 2:23 EDT
Multiple select is allowed for Repeating Dynamic Layout
Hi,
This is an issue with Radio Button on Grid. I am using Repeating Dynamic Layout for repeating an entire section. I am simply trying to build a UI where user can select only 1 out of this repeating Grid but PRPC is allowing multiple select. I tried the following 3 radio button controls but none of them works. I know radio button does not work well with Repeating Grid but it is even worse with Repeating Dynamic Layout.
1. pzGridRadioButton => Multiple selection is allowed (which is not correct behavior for radio button nature)
2. pyRadiobuttonsSelectable => Radio button won't even show up on UI at runtime
3. pxRadioButtons => Shows two radio buttons (True & False) for one Dynamic Layout (I just need one radio button without value)
I was advised to build a customized Java Script code or activity but actually none of them worked well in the past. Is there any stable code that works fine with above situation?
https://pdn.pega.com/support-articles/events-radio-buttons-are-not-triggered
Thanks,
Hi,
You can create a custom control with below details. It is just an extension of pzGridRadioButtons.
<pega:save name="strRefName" ref="$this-name" />
<pega:save name="strValue" ref="$this-value" />
<pega:include name="Messages"/>
<%
String output = tools.getSaveValue("strRefName").replaceAll("[\\d]" , "");
%>
<input type="hidden" name="<p:r n='$this-name'/>" value="false"/>
<input type=radio name="<p:r n='$this-name'/>"
onclick="setOtherRadioToFalse(this, event );" value="true"
<pega:when test='$this-value=="true"'>
checked="true" id = "<%=output%>"
</pega:when>
<pega:choose>
<pega:when test="$mode-input">
</pega:when>
<pega:otherwise>
disabled="disabled"
</pega:otherwise>
</pega:choose>
/>
Hi,
You can create a custom control with below details. It is just an extension of pzGridRadioButtons.
<pega:save name="strRefName" ref="$this-name" />
<pega:save name="strValue" ref="$this-value" />
<pega:include name="Messages"/>
<%
String output = tools.getSaveValue("strRefName").replaceAll("[\\d]" , "");
%>
<input type="hidden" name="<p:r n='$this-name'/>" value="false"/>
<input type=radio name="<p:r n='$this-name'/>"
onclick="setOtherRadioToFalse(this, event );" value="true"
<pega:when test='$this-value=="true"'>
checked="true" id = "<%=output%>"
</pega:when>
<pega:choose>
<pega:when test="$mode-input">
</pega:when>
<pega:otherwise>
disabled="disabled"
</pega:otherwise>
</pega:choose>
/>
include below script in a JS file and add it in the harness
<script>
function setOtherRadioToFalse(Obj, event){
var currentName = Obj.name;
if(typeof(Obj.id)=="undefined" || Obj.id=="")
Obj.id = currentName.replace(/[\d]/g, "");
var radioButtonsList = pega.util.Dom.getElementsById(Obj.id);
var len = radioButtonsList.length;
for(var i=0; i<len ; i++){
if(radioButtonsList[i]){
if(radioButtonsList[i].name != currentName){
radioButtonsList[i].checked = false;
}
}
}
}
</script>
Please let me know if you find any other easy way to handle it.
Hope it helps.
Thanks,
Ananda Bhat