+ Start a Discussion

Column with "Select All" Checkbox

I'd like to have the "Select All" functionality on a column in a pageBlockTable. It exists in various parts of Salesforce, where it is a checkbox beside the column title, which will select all or deselect all checkboxes in that column. How would I go about doing this for the following code:
<apex:pageBlockTable value="{!allIOs}" var="io">
 <apex:column headerValue="Select">
  <apex:inputCheckbox value="{!io.mfd}"/>

Thanks for any tips in advance!
I think the way I would do this is instead of giving a headerValue of "Select" I'd give it a headerFacet with another inputCheckboxes.  I have not tried this out but I'd think it would be something like this:

<apex:pageBlockTable value="{!allIOs}" var="io" id="table">
  <apex:facet header="name">
    <apex:inputCheckbox value="{!allSelected}">
      <apex:actionSupport event="onchange" rerender="table"/>
  <apex:inputCheckbox value="{!io.mfd}"/>

 and then in setAllSelected, you'd loop through getAllIOs and call setMfd(true).

Just a heads up. I noticed some strange behavior in IE6 if you use the event="onchange" with a check box. At least when rerendering it doesn't do anything until you click the check box and then click away, almost like an onblur event. Using onclick seemed to do the trick.
Thanks guys. The onchange issue is a "feature" of Internet Explorer in general (including IE7) and with a checkbox I use "onclick" instead. Thanks for the feedback guys