Created
April 28, 2013 04:29
-
-
Save tyoshikawa1106/5475882 to your computer and use it in GitHub Desktop.
-- 参考サイト --
Checking The Boxes, Getting The Input:
http://www.laceysnr.com/2013/04/checking-boxes-geting-input.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class CheckingTheBoxesController { | |
public Map<Id, Boolean> selected {get; set;} | |
public List<Opportunity> opportunities {get; set;} | |
public Boolean forAll {get; set;} | |
public CheckingTheBoxesController() { | |
this.selected = new Map<Id, Boolean>(); | |
this.opportunities = new List<Opportunity>(); | |
for(Opportunity o : [select Id, Name from Opportunity]) | |
{ | |
this.selected.Put(o.Id, false); | |
this.opportunities.Add(o); | |
} | |
} | |
public void ToggleAll() | |
{ | |
for(Id oppty : this.selected.keyset()) | |
{ | |
this.selected.Put(oppty, this.forAll); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="CheckingTheBoxesController" tabStyle="Opportunity" id="page"> | |
<apex:form> | |
<apex:pageBlock> | |
<apex:pageBlockTable value="{!opportunities}" var="o" id="list"> | |
<apex:column style="width:30px"> | |
<apex:facet name="header"> | |
<apex:inputCheckbox value="{!forAll}"> | |
<apex:actionSupport event="onchange" action="{!ToggleAll}" rerender="list"/> | |
</apex:inputCheckbox> | |
</apex:facet> | |
<apex:inputCheckbox value="{!selected[o.Id]}"/> | |
</apex:column> | |
<apex:column> | |
<apex:outputField value="{!o.Name}"/> | |
</apex:column> | |
</apex:pageBlockTable> | |
</apex:pageBlock> | |
</apex:form> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment