One of the things XPages are currently missing is a simple control for radio or checkboxes. There are 'other' controls for them, but they aren't very robust yet. What I mean by that is you can't easily specify to have several columns that match up, you can have them all go horizontal or vertical, but I'm working on a process and I'd like to have the checkboxes spread out over two columns. After some experimentation, I finally created two checkbox groups, one in each cell of a table, the problem them comes up that it's a bit difficult to get these two different groups to coordinate their values.
Here is a picture of my end result. What I do is on pageLoad, I get the values I want to work with via @DBColumn, then I iterate through them moving the value to an array that holds either the even or the odd numbered ones:
var getCent = @DbColumn(@DbName(),"luCheckBox",1);
var evenArray = [];
var oddArray = [];
for(i=0;i<getCent.length;i++){
if (@Modulo(i, 2) == 0) {
oddArray[oddArray.length]=getCent[i];
}else{
evenArray[evenArray.length]=getCent[i];
}
}
sessionScope.put("evenArray", evenArray);
sessionScope.put("oddArray", oddArray);
I put both into a sessionScope so they can be retrieved Each checkBoxGroup puts it's values into another sessionScope variable so I can combine them.
<xp:checkBoxGroup id="checkBoxGroup1" value="#{sessionScope.oddRtn}" layout="pageDirection">
<xp:selectItems>
<xp:this.value>
<![CDATA[#{javascript:sessionScope.get("oddArray");}]]>
</xp:this.value>
</xp:selectItems>
</xp:checkBoxGroup>
I can get this from the QuerySave event:
var comboArray = sessionScope.get("oddRtn").concat(sessionScope.get("evenRtn"));
document1.replaceItemValue("checkArrayCombo", comboArray);
This pumps them into a field on the document, but it could go into another scoped variable or whatever. I little working could get more than 2 columns. Here is a full XML of the page.
Cheers,
Brian