Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Radio button selection does not work across pages in grid

SA-51279

Summary



A repeating grid is configured with Page List as source and radio button (pyRowSelected) as one of the columns.

When pagination is enabled, radio button selection does not work across the pages in the repeating grid.

On the first page of the repeating grid, a user selects one radio button (that is, one record). Then the user uses pagination to navigate to the second, third, and other pages. When the user selects a radio button on one of the subsequent pages and goes back to the first page, the radio button on the first page is still selected. The selection of the last radio button on a subsequent page should have overridden the selection of the radio button on the first page.



Refer to the following images to understand the issue.

Here is Page 1:


Here is Page 2:


Error Messages



Not Applicable


Steps to Reproduce

  1. Configure a grid sourced with a Page List.
  2. Add radio button as one of the columns in the grid.
  3. Apply pagination format to the grid.
  4. Run the case and try selecting more than one record in the grid.
    Only one value should be selected, but two are shown as selected.


Root Cause


 
The repeating grid does not select and clear the values in the clipboard as expected.

When pagination happens, it does not know if it has to deselect any row. The clearing of radio buttons is client-only; even the values do not propagate to the clipboard.

Resolution



Perform the following local change:
 

1. Include the following snippet in the UserWorkForm:
 

<script>
pega.u.d.attachOnload(function() {
if (pega.ui && pega.ui.grid) {
pega.ui.grid.prototype.setOtherRadioToFalse = function(element, event) {
var currentName = element.name;
if (typeof(element.id) == "undefined" || element.id == "")
element.id = currentName.replace(/[\d]/g, "");
var radioButtonsList = pega.util.Dom.getElementsById(element.id, this.gridDiv);
var len = radioButtonsList.length;
for (var i = 0; i < len; i++) {

if (radioButtonsList[i]) {
if (radioButtonsList[i].name != currentName) {
radioButtonsList[i].checked = false;
}
}
}
var currentRowRef = pega.ui.property.toReference(element.name);

var activityUrl = SafeURL_createFromURL(pega.u.d.url);
activityUrl.put("pyActivity", "@baseclass.SetOtherRadioToFalse");
activityUrl.put("propRef", currentRowRef);

pega.u.d.asyncRequest("POST", activityUrl);
};
}
}, true);
</script>

 

2. Create an activity @baseclass.SetOtherRadioToFalse on the server with one Java step and paste the following code into the step:

String propertyReference = tools.getParamValue("propRef"); 

// Get the property name 
String propertyName = propertyReference.substring(propertyReference.lastIndexOf('.') + 1); 

// Get the page list name 
String rowPageRef = propertyReference.substring(0, propertyReference.lastIndexOf('.')); 
String pageListRef = rowPageRef.substring(0, propertyReference.lastIndexOf('(')); 
int rowNumber = Integer.parseInt(rowPageRef.substring(propertyReference.lastIndexOf('(') + 1, propertyReference.lastIndexOf(')'))); 

// oLog.error(pageListRef + " | " + rowNumber + " | " + propertyName); 
Iterator plIterator = tools.getProperty(pageListRef).iterator(); 
while(plIterator.hasNext()) { 
ClipboardPage rowPage = ((ClipboardProperty) plIterator.next()).getPageValue(); 

if (rowPage.getReference().equals(rowPageRef)) { 
rowPage.getProperty(propertyName).setValue(true); 
} else { 
rowPage.getProperty(propertyName).setValue(false); 

}

 


3. If the response is slow and the value is not being passed to the clipboard after the activity is run, then the pyStreamname value on the clipboard is 'ActivityStatusSuccess' after the activity is run instead of  'Perform'.

To avoid this scenario, add a Refresh Current Harness action onClick of a button.

By the time Refresh is done, the value in the clipboard (Perform) is passed and the repeating grid works as expected.

See also, 
https://community.pega.com/knowledgebase/articles/radio-buttons-and-check-boxes-repeating-grids-misbehave.
 

 



 

Published May 14, 2019 - Updated October 8, 2020

Was this useful?

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us