Activity Forums Salesforce® Discussions Can we make nested page block table in Salesforce?

  • shariq

    Member
    July 19, 2017 at 1:02 pm

    I want to make page block table inside a page block table, how it can be done, please explain it with the example?

  • Aman

    Member
    July 19, 2017 at 1:33 pm

    Hello Shariq,

    yes ,we can make nested Page block table. you can refer to the below given visualforce Page and Apex class.

    visualforce Page

    <apex:page controller="SearchAccountCon" tabStyle="Account">
    <apex:form >
    <apex:pageMessages />
    <apex:inputText value="{!searchString}" />
    <apex:commandButton value="search" action="{!search}"/>
    <apex:pageBlock >
    <apex:pageBlockTable value="{!acct}" var="acc">
    <apex:column value="{!acc.Id}" />
    <apex:column value="{!acc.description}" />
    <apex:column >
    <apex:pageBlockTable value="{!acc.contacts}" var="c">
    <apex:column value="{!c.Id}"/>
    <apex:column value="{!c.LastName}"/>
    </apex:pageBlockTable>
    </apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
    </apex:page>

    Apex class

    public class SearchAccountCon {
    public static String searchString {get; set; }
    public static List<Account> acct{get;set;}

    public static void search(){
    try{
    acct= Database.query('Select Name, description,(select id, Name,LastName From Contacts) From Account WHERE Name LIKE \'%'+searchString+'%\' Limit 100');
    system.debug('ddd'+acct);
    }
    catch(Exception e){
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter Account site'));
    }
    }

    }

     

     

  • Parul

    Member
    September 16, 2018 at 12:43 pm

    Yes, we can make nested page block table in Salesforce

    Ex:

    <apex:page controller="dbPracticeChangesController">
    <apex:form >
    <apex:pageblock >
    <apex:pageblocktable value="{!ChangeList}" var="cs">
    <apex:column headervalue="Competency">
    <apex:outputtext value="{!cs.Name}"/>
    </apex:column>
    <apex:column headervalue="Rollup Data">
    <apex:facet name="Facet Name">
    </apex:facet>
    <apex:pageblocktable value="{!cs.dbPracticeChanges__r}" var="db">
    <apex:column headervalue="Name">
    <apex:outputtext value="{!db.Name}"/>
    </apex:column>
    <apex:column headervalue="Late Start">
    <apex:outputtext value="{!db.Late__c}"/>
    </apex:column>
    </apex:pageblocktable>
    </apex:column>
    </apex:pageblocktable>
    </apex:pageblock>
    </apex:form>
    </apex:page>

     

    Thanks

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos