0
votes

I'm not using checkboxgroup because in my real application there are still other controls inside the repeat control. Below is my sample source:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:repeat id="repeat1" rows="30" var="curRow" indexVar="rowIndex"><xp:this.value><![CDATA[#{javascript:['option 1', 'option 2', 'option 3']}]]></xp:this.value>

        <xp:table>
            <xp:tr>
                <xp:td>
                    <xp:checkBox text="#{javascript:curRow}"
                        id="checkBox1">

                    <xp:eventHandler event="onchange" submit="true"
                        refreshMode="complete">
                    </xp:eventHandler></xp:checkBox>
                </xp:td>

            </xp:tr>
        </xp:table></xp:repeat>
    <xp:button id="button1" value="Submit" disabled="#{javascript:!getComponent('checkBox1').isChecked()}"></xp:button>
    </xp:view>

It would be better if this is achievable in CSJS.

EDIT

@stwissel

I've disabled the button by default and in the client-side onchange event of the checkbox, I put the following code:

var a=dojo.query('input:checked', 'view:_id1').length;
if(a!=3){
    alert('Not yet!');
    document.getElementById("#{id:button1}").removeAttribute("disabled");
}else{
    alert('Done! All checkboxes are checked!');
    document.getElementById("#{id:button1}").setAttribute("disabled", true);
}

Those alert seems to be working fine if I use them. But the button is still disabled. I've enabled all 3 Dojo options of the XPage. Setting the onchange to partial refresh the button also did nothing. Anything that I missed?

1

1 Answers

1
votes

Solve that in CSJS, a roundtrip each time you click on a checkbox isn't very performant. The trick here: give the checkboxes a class, so you can use dojo.query to get a handle on all of them and then loop through them. On the first false you return. If you didn't return you reset the disabled value. Should be way faster than the roundtrips