function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Issues with select All checkbox and header data binding

 I'm am trying to create a simple selectAll check box at the top of my table but I can not figure out why this is not working. It's as if the data binding is not occurring when the check box is located in the header section of the table. If I remove the check box from the table it works fine.
This uses standard fields so it should be easy to copy and paste to reproduce.


<c:resellerAccountSearch />


<apex:component controller="resellerAccountSearch" >
<apex:form >
<apex:pageblock >

<apex:inputText value="{!searchValue}" id="searchtext"/>
<apex:commandButton value="Search" action="{!search}" rerender="results" status="search"/>

<!-- This check box works fine but if it is in the header section below it doesn't work
<apex:inputCheckBox value="{!selectAllCheckbox}">
<apex:actionSupport event="onclick" action="{!selectAll}" rerender="results"/>
</apex:inputCheckBox> -->

<apex:actionStatus id="search">

<apex:facet name="start">
<strong>Retrieving data... </strong>

<apex:facet name="stop">

<apex:pageblockTable value="{!cAccounts}" var="c" id="results">
<apex:column >
<apex:facet name="header">
<apex:inputCheckBox value="{!selectAllCheckbox}">
<apex:actionSupport event="onclick" action="{!selectAll}" rerender="results"/>
<apex:inputCheckBox value="{!c.selected}"/>
<apex:column value="{!c.acct.Name}"/>
<apex:column value="{!c.acct.BillingCity}"/>
<apex:column value="{!c.acct.CreatedDate}"/>
<apex:column value="{!c.acct.LastModifiedDate}"/>
<apex:column value="{!c.acct.Id}"/>



public class resellerAccountSearch {

public String searchValue {get; set;}
public List<Account> results {get; set;}
public List<cAccount> cAccounts {get; set;}
public Boolean selectAllCheckbox {get; set;}

public resellerAccountSearch(){
results = new List<Account>();
cAccounts = new List<cAccount>();

public PageReference search(){

if(searchValue.length() > 1){
searchValue = '*'+searchValue+'*';

List<List<SObject>> searchList = [FIND :searchValue IN NAME FIELDS RETURNING Account(Id, Name, BillingCity, CreatedDate, LastModifiedDate order by LastModifiedDate desc )];
results = ((List<Account>)searchList[0]);

for(Account acct: results){
cAccounts.add(new cAccount(acct));
return null;

public PageReference selectAll(){
for(cAccount acct : cAccounts){

if(selectAllCheckbox == true){
acct.selected = true;
acct.selected = false;
return null;

public class cAccount{
public Account acct {get; set;}
public Boolean selected {get; set;}

public cAccount(Account a){
this.acct = a;
selected = false;



Message Edited by TehNrd on 01-22-2009 03:21 PM
Hi Jason,

I just did the same yesterday and in fact i had to introduce a small javascript function on the "onclick" event of the "select all check box".
The first thing i did is to add an Id to the InputCheckBox :

<apex:inputCheckBox value="{!c.selected}" Id="selectLine"/>

Then i created this small javascript function :
function checkAll(cb){
    var inputElem = document.getElementsByTagName("input");
    for(var i=0; i<inputElem.length; i++){
            inputElem[i].checked = cb.checked;

 Finally i plugged this function to the onclick event of the select all check box :
<apex:inputCheckBox value="{!selectAllCheckbox}" onclick="checkAll(this)"> 

It works quite good.
Hope this can help you.


Thanks for confirming this behavior. This appears to be a bug so I have opened a case (02308648).

I try to stay away from Javascript and use apex as much as possible but thanks for the workaround. I must admit it is quicker though.

Message Edited by TehNrd on 12-16-2008 02:46 PM
Confirmed as bug. Work around above is the recommended solution.