You need to sign in to do that
Don't have an account?

Regarding displaying the records when we clikc on checkbox
Hi Experts,
Add check boxes to a list of records, a check box in the heading , when the header check box is cheked all the check boxes in the list are check and vice versa. please provide me with sameple code please
Thanks in advance
Hello Aaditya,
Yes i Have a best example for this, accoring to your problem,
I give you a sample code for that
VF page:-
<apex:pageblock id="pgblck">
<apex:pageblocktable value="{!WrapperList}" var="wraprec">
<apex:column value="{!wraprec.accRec.name}"/>
<apex:column value="{!wraprec.accRec.accountnumber}"/>
<apex:column value="{!wraprec.accRec.annualrevenue}"/>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectall()"/>
</apex:facet>
<apex:inputCheckbox value="{!wraprec.checkflag}" />
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
<apex:actionFunction name="selectallmethod" action="{!selectallnone}" rerender="pgblck"/>
</apex:form>
<script type="text/javascript">
function selectall() {
selectallmethod();
}
</script>
</apex:page>
Controller Method:-
Public with sharing class checkAllcolumnDemocontroller {
Public List<wrapperclass> wrapList {get;set;}
Public boolean checked{get;set;}
Public checkAllcolumnDemocontroller(){
checked = false;
}
Public void selectallnone(){
if(!checked)
checked = true;
else
checked = false;
}
Public List<wrapperclass> getWrapperList(){
wrapList = New List<wrapperclass>();
for(Account acc:[Select name,accountnumber,id,annualrevenue,description from account limit 5]){
if(!checked)
wrapList.add(New wrapperclass(acc,false));
else
wrapList.add(New wrapperclass(acc,true));
}
return wrapList;
}
Public class wrapperclass{
Public account accRec{get;set;}
Public boolean checkFlag{get;set;}
Public wrapperclass(account acc,boolean flag){
accRec = acc;
checkFlag = flag;
}
}
}
Thank You and If this post helps you, Mark it as solution and please throw a Kudos by clicking Star ***
Mike Kaurav | Salesforce Developer | Mind Digital Group
HI Kaurav,
Thakns for the reply really super example u gave me its working fine but , i didnt got these lines plese can u explain or write comment for everyline please.
or(Account acc:[Select name,accountnumber,id,annualrevenue,description from account limit 5]){
if(!checked)
wrapList.add(New wrapperclass(acc,false));
else
wrapList.add(New wrapperclass(acc,true));
Thanks in advance please