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
AnumcaAnumca 

Displaying Hierarchy of a custom Object

Hi All

 

   I have facing the problem when I am displaying the hierarchy of a custom object.

 

my requirement is:

 

If I am having the parent record  parent1,under this we have the child records.

 

I need to display    parent1     under this ineed to display 

                                child1   if it is having the childs again, we need to display 

                              child2 

 

 for this i wrote the code  

 

controller:

 

 

public class udahierarchy

 

{

 

UDA_Catalog__c udadata;

 

public set<id> tset=new set<id>();

 

public set<id> t1set=new set<id>();
public boolean showchild{set;get;}
public boolean showchild1{set;get;}
public boolean showparent{set;get;}
public list <UDA_Catalog__c> ulist=new list<UDA_Catalog__c>();
public list<UDA_Catalog__c> tlist=new list<UDA_Catalog__c>();
public list<UDA_Catalog__c> t1list=new list<UDA_Catalog__c>();
public udahierarchy()
{
ulist.clear();
showchild1=true;
showchild=true;
showparent=true;
for(UDA_Catalog__c u:[select id,name,Lookup__c,UDA_Catalog__c,UDA_Catalog__r.id  from UDA_Catalog__c where UDA_Catalog__r.id =: null])
{
ulist.add(u);
}
}
public list<UDA_Catalog__c> getdata()
{
return ulist;
}
public void udadata1()
{
tlist.clear();
showchild1=true;
showchild=true;
showparent=true;
id i=apexpages.currentpage().getparameters().get('oid');
for(UDA_Catalog__c uu:[select id from UDA_Catalog__c where id=:i])
{
tset.add(uu.id);
}
for(UDA_Catalog__c  t:[select name from UDA_Catalog__c where UDA_Catalog__c in:tset])
{
tlist.add(t);
}
}
public list<UDA_Catalog__c> getdata1()
{
return tlist;
}
public void udadata2()
{
t1list.clear();
showchild1=true;
showchild=true;
showparent=true;
id i=apexpages.currentpage().getparameters().get('kid');
for(UDA_Catalog__c u1:[select id from UDA_Catalog__c where id=:i])
{
t1set.add(u1.id);
}
for(UDA_Catalog__c  t1:[select name from UDA_Catalog__c where UDA_Catalog__c in:t1set])
{
t1list.add(t1);
}
}
public list<UDA_Catalog__c> getdata2()
{
return t1list;
}
}

 

 

 

 

 

 

 

page

 

 

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

  <apex:form >

 

   <apex:pageBlock >

     <apex:pageBlockTable value="{!data}" var="k" rendered="{!showparent}">

        <apex:column headerValue="Parent UDA Catalog ID">

         <apex:commandLink value=" {!k.name}" action="{!udadata1}">

         <apex:param name="oid" value="{!k.id}"/>

         </apex:commandLink>

        </apex:column>

 

       </apex:pageBlockTable>

       <apex:pageBlockTable value="{!data1}" var="c" rendered="{!showchild}">

        <apex:column headerValue="UDA Catalog Child">

         <apex:commandLink value=" {!c.name}" action="{!udadata2}">

         <apex:param name="kid" value="{!c.id}"/>

         </apex:commandLink>

        </apex:column>

       </apex:pageBlockTable>

       <apex:pageBlockTable value="{!data2}" var="c1" rendered="{!showchild1}">

        <apex:column headerValue="UDA Catalog Childs" value="{!c1.name}"/>

       </apex:pageBlockTable>

   </apex:pageBlock>

  </apex:form>

</apex:page>

 

This code is working

 

But  i need design part  like this

 

 

when we click on the parent ,it will display the child,& click on child it will display the childs. without closing the parent window, means with in the parent only we have to diplay the childs(i.e without having too many pageblock tables)

 

 

pls help me 

 

 

Thanks &  Regards

 

Anu....