You need to sign in to do that
Don't have an account?
smitra
how to display SOQL query result in visualforce page
Hi All,
I have a SOQL query result in controller like this
(Lead:{Name=Bertha Boxer, Phone=(850) 644-4200, Id=00Q9000000EJ3FDEA1, LeadSource=Web, City=Tallahassee}, Lead:{Name=Phyllis Cotton, Phone=(703) 757-1000, Id=00Q9000000EJ3FEEA1, LeadSource=Web}, Lead:{Name=Jeff Glimpse, Phone=886-2-25474189, Id=00Q9000000EJ3FFEA1, LeadSource=Phone Inquiry}
I want to display the result in tabuler format in visual force page.
Please let me know how to display the result
I have a SOQL query result in controller like this
(Lead:{Name=Bertha Boxer, Phone=(850) 644-4200, Id=00Q9000000EJ3FDEA1, LeadSource=Web, City=Tallahassee}, Lead:{Name=Phyllis Cotton, Phone=(703) 757-1000, Id=00Q9000000EJ3FEEA1, LeadSource=Web}, Lead:{Name=Jeff Glimpse, Phone=886-2-25474189, Id=00Q9000000EJ3FFEA1, LeadSource=Phone Inquiry}
I want to display the result in tabuler format in visual force page.
Please let me know how to display the result
for example --> Public List<Acccount> accList{get;set;}
Use query in your constructor if you want to display the values when the page initialize time,
accList = [Select name,phone from Account];
To display the above query result in visualforce page as a tabular format use like below,
Hope this will helpful to you..! If you need clarification let me know..!
Thanks..
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000952sIAA
Hi Smitra,
If you have the query, put that in an list & then you can use the pageblocktable attribute to show the details on Visualforce Page in the form of a Table.
<!-- Apex: -->
public List<String> getMyLeadList(){
myLeadList = [Your Query];
return myLeadList;
}
List<String> myLeadList = [Your Query];
<!-- Page: -->
<apex:page Controller="yourcontroller">
<apex:pageBlock title="My Content">
<apex:pageBlockTable value="{!myLeadList}" var="item">
<apex:column value="{!item.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Hope this fulfills your requirement.
Important :
Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for others benefits.
Thank You
Problem here is I want to display in pageblock table but dont know the exact object name (As it is dynamic search it could be account,contact lead or any custom object as well).So the query might return list of Account,Lead case or any custom objects.
Please suggest me how to display for this dynamic entitis
initially i thought of a wrapper class where i selected first 4 attributes of the returnd list after soql query(example name,email,phone) but can u please help with the approach
http://www.sfdcpoint.com/salesforce/sosl-example-in-salesforce/
for example:
<apex:pageblockTable value="{!conList}" var="con">
<apex:column value="{!con.name}"/>
<apex:column value="{!con.email}"/>
</apex:pageblockTable>
But the problem is when i want to render the search result in vf page it could be anything..its not a predetermined set of attributed that I want to display..There should be some generic holder which will keep track of the attributes that i want to display..considering my example..if it is lead {Name=Bertha Boxer, Phone=(850) 644-4200, Id=00Q9000000EJ3FDEA1, LeadSource=Web, City=Tallahassee},
Then in visula force page it should appear like
Name|Phone|Id|LeadSource|City
Bertha|(850) 644-4200|Web|Tallahassee
What I assume as your problem is -
You have a query that can result many records from different object & you need to show them on a Visualforce Page. Try understanding the usability in this snippet of code. It would help.
If you nee to add more functionalities to the search results, the best would be bob's blog here (http://bobbuzzard.blogspot.co.uk/2011/06/execute-custom-search-when-opening-page.html),
Hope this fulfills your requirement.
Important :
Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for others benefits.
Thank You