+ Start a Discussion
AnnaTAnnaT 

Show parent and child objects in one table

I'd like to show both parent and child objects in one table.

But I don't know how to show "Status__c" in VF page.

Please help me...

 

Here is my code.

 

  part of my Apex class.

setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
         [Select r.Phase__c, r.Name, 
                 r.Item_No_seq__c, r.Id,
                 (Select Status__c From Ichthys_RFT__r)  
            From RFT_Category__c r 
           where r.Location__c includes (:location) order by r.Item_No_seq__c]));

 my VF page.

 If I try to save this code, the error occurrs. "Error: Unknown property 'VisualforceArrayList.Status__c'"

<apex:pageBlockTable id="block" value="{!lstREFCategory}" var="rftObject" style="width:100%" >
  <apex:column headerValue="No" >
  <apex:Outputtext value="{0,number,###,###,###,###}">
  <apex:param value="{!rftObject.Item_No_seq__c}"></apex:param>
  </apex:outputtext>
  </apex:column>
  <apex:column style="width:200px"  >
    <apex:facet name="header">
        Phase
    </apex:facet>
    <apex:Outputtext value="{!rftObject.Phase__c}" style="width:50px" />
  </apex:column>
  <apex:column headerValue="Status">
  <apex:Outputtext value="{!rftObject.Ichthys_RFT__r.Status__c}" style="width:200px"/>
  </apex:column>
</apex:pageBlockTable>

 Thank you,

 Anna

Best Answer chosen by Admin (Salesforce Developers) 
ForcepowerForcepower

ok - got it, Anna. It looks like you'll need to iterate through rftObject.Ichthys_RFT__r since it's an ArrayList. Can you put it in a apex:repeat or a datatable and try running through all the statuses (Status__c)? See below:

 

<apex:pageBlockTable id="block" value="{!lstREFCategory}" var="rftObject" style="width:100%" >
  <apex:column headerValue="No" >
  <apex:Outputtext value="{0,number,###,###,###,###}">
  <apex:param value="{!rftObject.Item_No_seq__c}"></apex:param>
  </apex:outputtext>
  </apex:column>
  <apex:column style="width:200px"  >
    <apex:facet name="header">
        Phase
    </apex:facet>
    <apex:Outputtext value="{!rftObject.Phase__c}" style="width:50px" />
  </apex:column>
  <apex:column headerValue="Status">
     <apex:repeat value="{!rftObject.Ichthys_RFT__r}" var="item" >      <apex:Outputtext value="{!item.Status__c}" style="width:200px"/> <br />
</apex:repeat> </apex:column> </apex:pageBlockTable>

All Answers

ForcepowerForcepower
Anna,

Can you try this query instead (without changing the meaning)?
[Select r.Phase__c, r.Name,
r.Item_No_seq__c, r.Id,
r.Ichthys_RFT__r.Status__c
From RFT_Category__c r
where r.Location__c includes (:location) order by r.Item_No_seq__c]
AnnaTAnnaT

Thank you for your reply.

 

I tried it but the following error occurred when I save it.

 

Didn't understand relationship 'Ichthys_RFT__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. 

 

RFT_Category__c is a parent object and Ichthys_RFT__r is a child object.

 

Thank you,

Anna Tanaka

ForcepowerForcepower

ok - got it, Anna. It looks like you'll need to iterate through rftObject.Ichthys_RFT__r since it's an ArrayList. Can you put it in a apex:repeat or a datatable and try running through all the statuses (Status__c)? See below:

 

<apex:pageBlockTable id="block" value="{!lstREFCategory}" var="rftObject" style="width:100%" >
  <apex:column headerValue="No" >
  <apex:Outputtext value="{0,number,###,###,###,###}">
  <apex:param value="{!rftObject.Item_No_seq__c}"></apex:param>
  </apex:outputtext>
  </apex:column>
  <apex:column style="width:200px"  >
    <apex:facet name="header">
        Phase
    </apex:facet>
    <apex:Outputtext value="{!rftObject.Phase__c}" style="width:50px" />
  </apex:column>
  <apex:column headerValue="Status">
     <apex:repeat value="{!rftObject.Ichthys_RFT__r}" var="item" >      <apex:Outputtext value="{!item.Status__c}" style="width:200px"/> <br />
</apex:repeat> </apex:column> </apex:pageBlockTable>
This was selected as the best answer
AnnaTAnnaT

YES!! It works !!!!!!!!!!!!!!!!!!!!!!!!!!

Thank you very much! 

ForcepowerForcepower
Great! You're very welcome, Anna!!
Ram