0
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Activate" action="{!processSelected}" rerender="table"/>

                <apex:commandButton value="InActivate" action="{!processSelected}" rerender="table"/>

            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!contacts}" var="c" id="table">

<apex:column >

 <apex:facet name="header"><apex:inputCheckbox rendered="true">
<apex:actionSupport event="onclick" onsubmit="checkAll(this)" rerender="Selected_PBS"/>

</apex:inputCheckbox> 
</apex:facet>

<apex:inputCheckbox value="{!c.selected}" id="checkdone" rendered="true">

</apex:inputCheckbox>
<apex:actionSupport event="onclick"  rerender="Selected_PBS" >


</apex:actionSupport>
</apex:column> <!-- This is how we access the contact values within our cContact container/wrapper -->
                <apex:column value="{!c.con.Name}" />
                <apex:column value="{!c.con.Active__c}" />
                <apex:column value="{!c.con.Phone}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>





 <apex:commandButton action="{!Beginning}" title="Beginning" value="<<" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>
            <apex:commandButton action="{!Previous}" title="Previous" value="<" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>        
            <apex:commandButton action="{!Next}" title="Next" value=">" disabled="{!disableNext}" reRender="myPanel,myButtons"/>
            <apex:commandButton action="{!End}" title="End" value=">>" disabled="{!disableNext}" reRender="myPanel,myButtons"/>    

when I clicked on the next and again come to the previous then it remove the selected checkbox

1
  • It is definitely doable with your current structure. However, we need to see your controller code before telling you why your next button has removed the user data
    – Lance Shi
    Oct 5, 2016 at 5:46

1 Answer 1

0

1.Create a new set selectedConIdSet

2.On clicking Prev,Next,End functions,add the set of contact ids to this new set by looping through the contacts list and remove the set of unselected contact ids if it already exists in the selectedConIdSet

for(cContact c:contacts)
{
if(c.selected==true)
 selectedConIdSet.add(c.con.id);
else
 if(selectedConIdSet.contains(c.con.id)
 selectedConIdSet.remove(c.con.id);
}
}

and then proceed with next or previous action

3.Now loop through your method where you are getting the contacts and check whether the selectedConIdset contains the contacts.If it contains the contacts,make selected as true before adding it to contactsList.For eg conList is the list of contacts that you already have with you

for(contact c:conList)
{
  cContact c =new cContact();
  if(selectedConIdSet.contains(c.id))
    c.selected = true;
  c.contact = c;
 contacts.add(c);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.