Scenario:
Also Read: How to Create Pagenation In Visualforce?
Solution:
Visualforce Page:
Result:
Sometime We get the requirement to Show all the records in any object in a table.and selecting any record in table it will show the details of the record and associate related records also.
Also Read: How to Create Pagenation In Visualforce?
Solution:
We can do this in two ways. First method is by Using the Standard List Controller. And Second Method is Using the SOQL query to Retrieve the list of Records. Then finally display the list of records Using the Pageblocktable or Data table.
<apex:page standardController="Account" recordSetVar="Accounts" sidebar="false"> <apex:form id="form"> <apex:pageBlock title="Accounts List"> <apex:pageblocktable value="{!Accounts}" var="Acc" rows="5"> <apex:column headerValue="Name"> <apex:commandLink value="{!Acc.name}" rerender="page" > <apex:param name="aid" value="{!Acc.id}" /> <apex:param name="aname" value="{!Acc.name}" /> </apex:commandLink> </apex:column> <apex:column value="{!Acc.type}"/> <apex:column value="{!Acc.industry}"/> </apex:pageblocktable> </apex:pageBlock> <apex:pageblock id="page" title="{!$CurrentPage.parameters.aname}"> <apex:detail subject="{!$CurrentPage.parameters.aid}" relatedList="false"/> </apex:pageblock> </apex:form> </apex:page>For More Salesforce Real Time Examples
Result: