function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MeerMeer 

Self Join in SoQL

Hi,

I am new developer to Salesforce.. I have a custom object of 'Value' having the following feilds,

 

Name(Primary Key)

VSDesc__c(Description)

Parent_Value__c(Parent Value)

Child_Parent_Value__r(Look up)

 

now i want to have nested table in which each Parent should display its childs as shown here:

 

http://www.forcetree.com/2010/04/nested-tables-and-nested-queries-in.html

 

I have made the controller as :

 

//Control Class

 

public class ValueManager
{  
  public List<Seg1__c> getValue()
   {
List<Seg1__c> Values = [Select Name, (Select Name, VSDesc__c From Child_Parent_Value__r where Parent_Value__c <> null) From Seg1__c p where p.Parent_Value__c= null] ;
      return Values;  
  }
}

 

 

//Visual Page

 

<apex:page controller="ValueManager" showheader="false">

<apex:pageblock >

<apex:pageblocktable value="{!Value}" var="par">

<apex:column headervalue="Parent Value">
<apex:outputtext value="{!par.Name}"/>
</apex:column>

<apex:pageblocktable value="{!Value}" var="ch">
<apex:column headervalue="Description">
<apex:outputtext value="{!ch.Name}"/>
</apex:column>
</apex:pageblocktable>


</apex:pageblocktable>
</apex:pageblock>

</apex:page>

 

Can any one help me how can i acheive???


Best Answer chosen by Admin (Salesforce Developers) 
soofsoof

Replace your second (nested) <apex:pageBlockTable>...</apex:pageBlockTable> code with the following code:

 

<apex:column headervalue="Child Nested Table">
	<apex:pageblocktable value="{!par.Child_Parent_Value__r}" var="ch">
		<apex:column headervalue="Description">
			<apex:outputtext value="{!ch.Name}"/>
		</apex:column>
	</apex:pageblocktable>
</apex:column>

 

Hope this helps.

 

Thanks.