Subject: SOLUTION: How to select rows in a repeat control.
I was unable to get the editable checkboxes working directly. The problems I had were how to bind them and also how to update (full/partial). So, after stumbling across this article by the great Declan Sciolla-Lynch:
I was able to adapt his approach and achieve my goal. To select a row, the user clicks a link in the repeat row (not the checkbox itself), which saves the docunid to a sessionscope var for processing (checkbox now shows as checked). My processing button runs on each docunid and then clears the sessionscope var.
Here’s what I did… I still have a checkbox in each row of my repeat control even though it isn’t clickable. It’s simply there to show which rows have been selected. It’s computed and visible but not editable. The data binding formula for my checkbox is the following:
var str = getComponent(“RowString”).getValue();
var rowarr = str.split(“~”);
var docunid = rowarr[15];
var sel=sessionScope.FlagDocs;
if (sel==null || sel==“”){
return("");
}
else {
var newval=@If(@Contains(sel, docunid), "Y","");
if (newval=="Y"){
return("Y");
}
else {
return("");
}
}
(how you get your docunid may vary)
This code will compute whether the checkbox should show as checked or not. If the docunid is in the sessionscope var, then it shows checked, otherwise not.
This is the code in my link, which either adds the docunid to the var or removes it. (set to partial update the repeat control id)
var str = getComponent(“RowString”).getValue();
var rowarr = str.split(“~”);
var docunid = rowarr[15];
var sel=sessionScope.FlagDocs;
if (sel==null){
var newval = docunid;
}
else {
var newval=@If(@Contains(sel, docunid), @ReplaceSubstring(sel, docunid,""), sel+"~"+docunid);
}
sessionScope.FlagDocs = @Implode(@Trim(@Explode(newval,“~”)),“~”);
Pretty simple actually. Hope this helps someone else because I couldn’t find any other examples of how to do this.
Bob