To fetch data from Controller and display it in Visualforce page without using button, retrieve the record in the constructor.
Sample code:
Visualforce page:
<apex:page controller="Sample" >
<apex:form >
<apex:pageblock id="account" title="Account Details(Standard Object)" >
<apex:pageblockTable value="{!acc}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.AccountNumber}"/>
</apex:pageblockTable>
</apex:pageblock>
<apex:pageblock id="member" title="Member Details(Custom Object)">
<apex:pageblockTable value="{!mem}" var="m">
<apex:column value="{!m.Name}"/>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
Controller:
public with Sharing class Sample
{
public List<Account> acc {get;set;}
public List<Member__c> mem {get;set;}
public sample()
{
acc = [SELECT Name, AccountNumber FROM Account];
mem = [SELECT Name FROM Member__c];
}
}
Output:
Sample code:
Visualforce page:
<apex:page controller="Sample" >
<apex:form >
<apex:pageblock id="account" title="Account Details(Standard Object)" >
<apex:pageblockTable value="{!acc}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.AccountNumber}"/>
</apex:pageblockTable>
</apex:pageblock>
<apex:pageblock id="member" title="Member Details(Custom Object)">
<apex:pageblockTable value="{!mem}" var="m">
<apex:column value="{!m.Name}"/>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
Controller:
public with Sharing class Sample
{
public List<Account> acc {get;set;}
public List<Member__c> mem {get;set;}
public sample()
{
acc = [SELECT Name, AccountNumber FROM Account];
mem = [SELECT Name FROM Member__c];
}
}
Output:
hi
ReplyDeletei have one request
search the picklist value get the data on table formade using bootstrup method
Yes. Once you get the result from the apex convert it to JSON and use bootstrap methods to show it. Let me know if that works.
DeleteI want to know about the how to fetch data in custom object can you please share some suggestions about it. Thanks
ReplyDeleteIn the example used, Member__c is a custom object.
DeleteCan i know to display the data in another Vf page by clicking on button
ReplyDeleteTry this - https://blogs.perficient.com/2015/03/16/how-to-embed-visualforce-pages-in-visualforce-pages-issues-and-solution/
DeleteHi, Is it possible to display the related records below the record name which is selected/clicked. Let's say I am displaying List of Accounts based on search string. From the results if I clicked one record below the record name I need to display related contacts.
ReplyDeleteI haven't done this in VF and Apex.
DeleteYou can try lightning-tree-grid with row level action in Salesforce Lightning - https://www.infallibletechie.com/2020/07/lightning-tree-grid-with-row-level.html. In the above example, I have shown Account and it's related Contacts.
Hi, Thanks for your response.. Isn't it possible to achieve the same functionality using normal apex class and vf page. Since I'm not aware of Salesforce Lightning I am trying to achieve in that way.
DeleteCheck this - https://www.infallibletechie.com/2021/02/collapsible-and-expandable-sections.html
Delete