+ Start a Discussion
Mj12Mj12 

custom related list pagination

hi,

 

 

im trying to create my own custom campaign member related fields having the same exact output the campaign members related lists have.

 

here's my vs code:

--------------------------------------------------​--------------------------------------------------​----------------------------------------

<apex:page standardController="Campaign" extensions="CustomCampaignMemberCon">
<style>
    .fewerMore { display: none;}
</style>

 

<apex:form Id="frmCampaignmember" rendered="True">
    <apex:pageMessages />
    <apex:detail relatedList="true"></apex:detail>

    <apex:pageblock id="CustomList" title="Campaign Members">
        <apex:pageBlockTable Id="CampaignMemberList" value="{!Cmember}" var="cm" rendered="{!NOT(ISNULL(Cmember))}"  >       
 
            <apex:column HeaderValue="Action">      
                <apex:outputLink title=""
                    value="/{!cm.id}/e?retURL=/apex/{!$CurrentPage.Name}?id={!$CurrentPage.parameters.Id}"
                    style="color:#2E64FE">Edit
                </apex:outputLink>&nbsp;|&nbsp;
                <a href= "javascript&colon;if (window.confirm('Are you sure {!$CurrentPage.parameters.Id}?')) DeleteCampaignMember('{!cm.Id}');"
                 style="color:#2E64FE">Remove</a>    
            </apex:column>
 
            <apex:column value="{!cm.Status}"/>      
 
            <apex:column HeaderValue="First Name: User-{!$User.Id}">
                <apex:outputLink title="" value="/{!cm.Id}">
                <apex:outputText value="{!cm.Contact.FirstName}"/>
                </apex:outputLink>
            </apex:column>
           
            <apex:column HeaderValue="Last Name">
                <apex:outputLink title="" value="/{!cm.Id}">
                <apex:outputText value="{!cm.Contact.LastName}"/>
                </apex:outputLink>
             </apex:column>
            
            <apex:column value="{!cm.Contact.Title}"/>                  
            <apex:column value="{!cm.CreatedDate}"/>                              

        </apex:pageBlockTable>  

 

        <apex:outputLabel value="No records to display testing" rendered="{!(ISNULL(Cmember))}" styleClass="noRowsHeader"></apex:outputLabel>
   
    </apex:pageblock>

    <apex:actionFunction action="{!DeleteCampaignMember}" name="DeleteCampaignMember" reRender="frmCampaignmember" >  
        <apex:param name="campaignmemberid" value="" assignTo="{!SelectedCMId}"/>
    </apex:actionFunction>

</apex:form>

</apex:page>

 

 

 

here's my class:

--------------------------------------------------​--------------------------------------------------​----------------------------------------

public class CustomCampaignMemberCon {
    private List<CampaignMember> Cmember;
    private Campaign C;    

    public string SelectedCMId  {get;set;}

    public CustomCampaignMemberCon(ApexPages.StandardController controller)
    {this.C = (Campaign)controller.getRecord();}   

    //Listing of members   
    public List<CampaignMember> getCmember()   
    {       
        Campaign[] camp = [Select Id FROM Campaign where id = :C.id];       
        if (Camp.size() > 0)        
        {
            //return null;       
            Cmember= [Select Id,Status
                            ,Contact.FirstName
                            ,Contact.LastName
                            ,Contact.Title
                            ,CreatedDate
                      from CampaignMember where Campaignid = :Camp[0].id];       

            return Cmember;   
        }
        else
        {return null;}
           
    }

    //Deletion of members
    public void DeleteCampaignMember()  
    {     
        // if for any reason we are missing the reference      
        if (SelectedCMId == null)
        {return;}          
       
        // find the account record within the collection     
        CampaignMember tobeDeleted = null;     
        for(CampaignMember cm : Cmember)      

            if (cm.Id == SelectedCMId  )
            {         
                tobeDeleted = cm;         
                break;      
            }           
            if (tobeDeleted != null)
            {Delete tobeDeleted;}          
     }

       
}

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------

im having a hard time recreating this functionality Show 5 more » | Go to list (14) »

 

 

thanks in advance,

mj12