You need to sign in to do that
Don't have an account?
sanjay dubey 19
on visualforce lastname firstname and phone is not visible my code below
<apex:page controller="wrappersanjay">
<script type="text/javascript">
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:commandButton value="selected contact" action="{!processSelected}"/>
<apex:pageBlockSection columns="2">
<apex:pageBlockTable value="{!wrplist}" var="wr">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!wr.checkbox}" id="inputId"/>
</apex:column>
<apex:column value="{!wr.con.lastName}" />
<apex:column value="{!wr.con.firstname}" />
<apex:column value="{!wr.con.phone}" />
</apex:pageblocktable>
<apex:pageBlockTable value="{!conlist}" var="c" id="table2" title="Selected Accounts">
<apex:column value="{!c.lastname}" headerValue="Account Name"/>
<apex:column value="{!c.firstname}" headerValue="Billing State"/>
<apex:column value="{!c.Phone}" headerValue="Phone"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class wrappersanjay {
public List<wrapper100> wrplist {get;set;}
public list<contact> conlist{get;set;}
public wrappersanjay(){
if(wrplist == null){
wrplist = new list<wrapper100>();
for(contact c : [select id,lastname,firstname,phone from contact limit 10]){
wrplist.add(new wrapper100(c));
system.debug('%%%%%%%%%'+wrplist);
system.debug('#######'+c);
}
}
}
public void processSelected(){
conlist = new list<contact>();
for(Wrapper100 wrpobj : wrplist){
if(wrpobj.checkbox == true){
conlist.add(wrpobj.con);
}
}
}
public class wrapper100{
public contact con{get;set;}
public Boolean checkbox{get;set;}
public wrapper100(contact c){
contact con=c;
checkbox = false;
}
}
}
<script type="text/javascript">
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:commandButton value="selected contact" action="{!processSelected}"/>
<apex:pageBlockSection columns="2">
<apex:pageBlockTable value="{!wrplist}" var="wr">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!wr.checkbox}" id="inputId"/>
</apex:column>
<apex:column value="{!wr.con.lastName}" />
<apex:column value="{!wr.con.firstname}" />
<apex:column value="{!wr.con.phone}" />
</apex:pageblocktable>
<apex:pageBlockTable value="{!conlist}" var="c" id="table2" title="Selected Accounts">
<apex:column value="{!c.lastname}" headerValue="Account Name"/>
<apex:column value="{!c.firstname}" headerValue="Billing State"/>
<apex:column value="{!c.Phone}" headerValue="Phone"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class wrappersanjay {
public List<wrapper100> wrplist {get;set;}
public list<contact> conlist{get;set;}
public wrappersanjay(){
if(wrplist == null){
wrplist = new list<wrapper100>();
for(contact c : [select id,lastname,firstname,phone from contact limit 10]){
wrplist.add(new wrapper100(c));
system.debug('%%%%%%%%%'+wrplist);
system.debug('#######'+c);
}
}
}
public void processSelected(){
conlist = new list<contact>();
for(Wrapper100 wrpobj : wrplist){
if(wrpobj.checkbox == true){
conlist.add(wrpobj.con);
}
}
}
public class wrapper100{
public contact con{get;set;}
public Boolean checkbox{get;set;}
public wrapper100(contact c){
contact con=c;
checkbox = false;
}
}
}
Replace your wrapper100 class with the following.
Let me know how it goes.