You need to sign in to do that
Don't have an account?
Anupama
How to display List<List<sobject>> on VF page.
My query returns the output as List<List<sobject>>.
When I tried to read it from VF page, it throws error
Unknown property 'VisualforceArrayList.Aircraft__c' |
Here is the sample code, that i have written.
<apex:dataTable value="{!SearchFlights}"
var="flight" styleClass="list" rendered="{!NOT(ISNULL(SearchFlights))}">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!flight.Aircraft__c}"/>
</apex:column>
<apex:column >
Can anybody please explain me How to read List<List<sobject>> and display it on the on visualforce page.
You can't display sobjects on the page since it's a base class - You have to create your own Apex Classes that is able to store all of your fields from your object.
Alternatively, you can just define the type of object you are using instead of SObject.
Thanks for the reply.
I have the query which returns data from Master-child tables.
If I define object as of type Master, i was not able to access child related fields on VF page.
Is there any other way to define objects?
If you want to display a list of all child objects, you can use a repeat within a repeat.
<repeat value="OuterList" var="OuterElement">
<repeat value="OuterElement.ChildRelationName" var = "child">
<!-- Put your display code here-->
</repeat>
</repeat>
//Controller
List<List<SObject>> searchList = [FIND :e IN EMAIL FIELDS RETURNING
Contact (Id, Name, Email)];
contacts = (List<Contact>)searchList[0];
//Page
<apex:pageBlock title="Matching Contacts" rendered="{!email != null}">
<apex:pageBlockTable value="{!contacts}" var="contact" id="contactTable">
<apex:column >
<apex:facet name="header"><b>Name</b></apex:facet>
<apex:outputLink value="../{!contact.Id}">{!contact.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header"><b>Email</b></apex:facet>
{!contact.email}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
Hope this helps :)