1

I have a table with checkboxes which rerenders a table as the checkboxes are clicked. This works fine, except for when all the checkboxes are set back to unchecked. Then the table does not rerender.

Controller:

public List<Case> allCases;
public List<Id> selectedCaseIds{get;set;}
public List<CaseWrapper> caseList = new List<CaseWrapper>();

public PageReference getSelected(){
    selectedCaseIds.clear();
    for(CaseWrapper cw : caseList){
        if(cw.selected){
            selectedCaseIds.add(cw.ca.Id);
        }
    }
    return null;
}

public List<CaseWrapper> getCases(){
    for(Case c : allCases){
        caseList.add(new CaseWrapper(c));
    }
    return caseList;
}

public class CaseWrapper{
    public Case ca{get;set;}
    public Boolean selected{get;set;}

    public CaseWrapper(Case c){
        ca = c;
        selected = false;
    }
}

VF page:

    <apex:pageBlockTable value="{!cases}" var="c">
    <apex:column>
        <apex:inputCheckbox value="{!c.selected}" id="checkedOne">
            <apex:actionSupport event="onclick" action="{!getSelected}" rerender="mytable"/>
        </apex:inputCheckbox>
    </apex:column>
    <apex:column value="{!c.ca.CaseNumber}" headerValue="Case Number"/>
    <apex:column value="{!c.ca.RecordType.Name}" headerValue="Record Type"/>
</apex:pageBlockTable>
  • Do you have like a header checkbox that you are checking to deselect all the records at once and that's when the table doesn't rerender? I don't see the js part of the VF page that would do that for you, and that may be what your issue is??? – cricketlang Oct 16 '15 at 0:11
0

Give ID to your Table.

 <apex:pageBlockTable value="{!cases}" var="c" id="mytable">
            <apex:column>
                <apex:inputCheckbox value="{!c.selected}" id="checkedOne">
                    <apex:actionSupport event="onclick" action="{!getSelected}" rerender="mytable"/>
                </apex:inputCheckbox>
            </apex:column>
            <apex:column value="{!c.ca.CaseNumber}" headerValue="Case Number"/>
            <apex:column value="{!c.ca.RecordType.Name}" headerValue="Record Type"/>
        </apex:pageBlockTable>

Check it whether it is Working or Not

| improve this answer | |
  • The id myTable refers to another table on my Visualforce page, that's the one I'm trying to rerender. – fred Oct 15 '15 at 14:40
-1

The problem was actually to do with the table I was trying to re-render, which I didn't post in the original question.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.