function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
buggs sfdcbuggs sfdc 

Show related Child Records on Account page using inline visualforce page

Hi Experts,

On Account Page i wants to embed a new inline visual force page,which needs to show 2 custom objects ((entity__c,features__c) information(i mean need to show few columns from each table) on that inline visual force page.And here i written some basic code which is working,but now i wanted to add pagination for it because if the records are lot on prod environment,i need to show them on 10 records per page,also please help me out to increase my Page width its not fitting to the session which i created on account page.

for example:

Account1 record
          ||
          ||
          ||
 (entity__c,features__c) object columns(on Inline Visual Force Page)
 
<apex:page standardController="account" extensions="ShowRelatedrecords" showChat="false"  label="width :1000px" >
 
    <apex:form >
    <div id="my-timeline" style="width:1100px; border: 1px solid #aaa">
       <apex:pageBlock >
         <apex:pageBlockSection >
           
       
           <apex:pageBlockTable value="{!zqu}" var="sub" width="10000%">
           <div id="my-timeline" style="width:1500px; border: 1px solid #aaa">
              <apex:column value="{!sub.Name}"/>
              <apex:column value="{!sub.field1__c}"/>         
              <apex:column value="{!sub.field12__c}"/> 
              <apex:column value="{!sub.field123__c}"/>
              <apex:column value="{!sub.field1234__c}"/> 
              <apex:column value="{!sub.field12345__c}"/>
                       </div>
           <apex:column headerValue="child records">
            <apex:pageBlockTable value="{!sub.child__r}" var="con" width="10000%">
            <div id="my-timeline" style="width:1500px; border: 1px solid #aaa">
            <apex:column value="{!con.cfield1__c}"/>
            <apex:column value="{!con.cfield12__c}"/>
            <apex:column value="{!con.cfield123__c}"/>
              <apex:column value="{!con.cfield1234__c}"/>
              <apex:column value="{!con.cfield12345__c}"/> 
              </div>
              </apex:pageblockTable>
           
            </apex:column>
             
              
                </apex:pageblocktable>
           
         </apex:pageBlockSection>
 
       </apex:pageBlock>
          </div>
    </apex:form>
 
</apex:page>
public with sharing class ShowRelatedrecords {
 
public ShowRelatedrecords(ApexPages.StandardController controller) {

   }     
     
     public List<parent> zqu{
        get
        {
        return [select name, field1,field12,field123,field1234,field12345,(select name, cfield12,cfield123, cfield1234, cfield12345 from child) from Parent where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active'];
        
        }
      }  
 
 string qry = 'select name, field1,field12,field123,field1234,field12345,(select name, cfield12,cfield123, cfield1234, cfield12345 from child) from Parent where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active'';
        
        /****
         public ApexPages.StandardSetController con {
        get {
            if(con == null) {
            
                con = new ApexPages.StandardSetController(Database.getQueryLocator(qry));

                // sets the number of records in each page set
                con.setPageSize(10);
            }
            return con;
        }
        set;
    }
    
        public Boolean hasNext {
        get {
            return con.getHasNext();
        }
        set;
    }

    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
        }
        set;
    }

    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return con.getPageNumber();
        }
        set;
    }

    // returns the first page of records
     public void first() {
         con.first();
     }

     // returns the last page of records
     public void last() {
         con.last();
     }

     // returns the previous page of records
     public void previous() {
         con.previous();
     }

     // returns the next page of records
     public void next() {
         con.next();
     }

     // returns the PageReference of the original page, if known, or the home page.
     public void cancel() {
         con.cancel();
     }
     
    

  }



Please help me out with any similar code if anyone had.

Thanks In Advance!
SandhyaSandhya (Salesforce Developers) 
Hi,

Please refer below Bob Buzzard Blog which has sample code for the same.

http://bobbuzzard.blogspot.sg/2011/04/edit-parent-and-child-records-with.html
 
Hope this helps you!

If this helps you, please mark it as solved.

Thanks and Regards
Sandhya