+ Start a Discussion
punnoosepunnoose 

Tree not coming correctly

i am having a class

public class region{
public Integer region_id{get;set;}
public String region_name{get;set;}
public List<Integer> country_id{get;set;}
public list<String> country_name{get;set;}
}

 i have given a list of this class

when i tried to generate tree view withpage code

-------------------------

<apex:page Controller="Tree" showHeader="true" tabStyle="account">
<!-- Include the Jquery Script files -->
<link rel="stylesheet" href="{!URLFOR($Resource.Jtreeview,'/jquery.treeview.css')}"/>
<script src="{!URLFOR($Resource.Jtreeview,'/lib/jquery.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'/lib/jquery.cookie.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'/jquery.treeview.js')}" type="text/javascript"></script>
<!-- End of Javascript files -->
<script type="text/javascript">
        $(function() {
            $("#tree").treeview({
                collapsed: false,
                animated: "medium",
                control:"#sidetreecontrol",
                persist: "location"
            });
        })
</script><apex:form >
<br/> <br/> <br/>
<!-- Tree -->
<div class="treeheader" style="height:0px;">&nbsp;</div>
<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>
<ul id="tree">
    <apex:repeat value="{!Accounts}" var="parent">
        <li><strong><apex:inputCheckbox id="checkedone3">

</apex:inputCheckbox><apex:outputtext style="color:blue;" escape="false" value="{!parent.region_name}"/></strong>
             <ul>
                 <apex:repeat value="{!parent}" var="child">
                    <li><span class="formattextcon"><apex:inputCheckbox id="checkedone3">

</apex:inputCheckbox><apex:outputtext style="color:green;" escape="false" value="{!child.country_name}"/></span>
                 
                    </li>
                 </apex:repeat>  
             </ul>  
        </li>
    </apex:repeat>
</ul></apex:form>
<!-- End of Tree -->       
</apex:page>

-------------------------------------------------------

 i am getting a tree like this

 

 

  • Africa
    • [Algeria, Angola, Benin, Botswana, Burkina Faso, Burundi, Cameroon, Cape Verde, Central African Republic, Chad, Comoros, Congo (Brazzaville), Democratic Republic of the Congo, Djibouti, Egypt, Equatorial Guinea, Eritrea, Ethiopia, Gabon, Gambia, Ghana, Guinea, Guinea-Bissau, Kenya, Lesotho, Liberia, Libya, Madagascar, Malawi, Mali, Mauritania, Mauritius, Morocco, Mozambique, Namibia, Niger, Nigeria, Réunion, Rwanda, São Tomé and Príncipe, Senegal, Seychelles, Sierra Leone, Somalia, South Africa, St. Helena, Sudan, Swaziland, Tanzania, Togo, Tunisia, Uganda, Western Sahara, Zambia, Zimbabwe]
  • Asia
    • [Afghanistan, Bangladesh, Bhutan, Brunei, Cambodia, China, East Timor, Hong Kong, India, Indonesia, Japan, Kazakhstan, Kyrgyzstan, Laos, Macao, Malaysia, Maldives, Mongolia, Myanmar, Nepal, North Korea, Pakistan, Philippines, Singapore, South Korea, Sri Lanka, Taiwan, Tajikistan, Thailand, Turkmenistan, Uzbekistan, Vietnam]
  • Caribbean
    • [Anguilla, Antigua and Barbuda, Aruba, Bahamas, Barbados, British Virgin Islands, Cayman Islands, Cuba, Dominica, Dominican Republic, Grenada, Guadeloupe, Haiti, Jamaica, Martinique, Montserrat, Netherlands Antilles, St. Kitts and Nevis, St. Lucia, St. Vincent and the Grenadines, Trinidad and Tobago, Turks and Caicos]
  • Central America
    • [Belize, Costa Rica, El Salvador, Guatemala, Honduras, Nicaragua, Panama]

 

 

i want in this format

  Central America

         Belize

        Costa rica

        El Salvador

        Guatemala

 what changes should i make to the page code

Regards

Punnoose

 

 

Navatar_DbSupNavatar_DbSup

HI,

Try the below code snippet as reference:

--------------- apex controller ----------------------

public class region{

public Integer region_id{get;set;}

public String region_name{get;set;}

public List<Integer> country_id{get;set;}

public list<String> country_name{get;set;}

}

--------- vf page -------------

<apex:page Controller="Tree" showHeader="true" tabStyle="account">

<!-- Include the Jquery Script files -->

<link rel="stylesheet" href="{!URLFOR($Resource.Jtreeview,'/jquery.treeview.css')}"/>

<script src="{!URLFOR($Resource.Jtreeview,'/lib/jquery.js')}" type="text/javascript"></script>

<script src="{!URLFOR($Resource.Jtreeview,'/lib/jquery.cookie.js')}" type="text/javascript"></script>

<script src="{!URLFOR($Resource.Jtreeview,'/jquery.treeview.js')}" type="text/javascript"></script>

<!-- End of Javascript files -->

<script type="text/javascript">

        $(function() {

            $("#tree").treeview({

                collapsed: false,

                animated: "medium",

                control:"#sidetreecontrol",

                persist: "location"

            });

        })

</script><apex:form >

<br/> <br/> <br/>

<!-- Tree -->

<div class="treeheader" style="height:0px;">&nbsp;</div>

<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>

<ul id="tree">

    <apex:repeat value="{!Accounts}" var="parent">

        <li><strong><apex:inputCheckbox id="checkedone3">

 

</apex:inputCheckbox><apex:outputtext style="color:blue;" escape="false" value="{!parent.region_name}"/></strong>

             <ul>

                 <apex:repeat value="{!parent}" var="child">

                    <li><span class="formattextcon"><apex:inputCheckbox id="checkedone3">

 

</apex:inputCheckbox><apex:outputtext style="color:green;" escape="false" value="{!child.country_name}"/></span>

                 <br/> <!—add this -->

                    </li>

                 </apex:repeat> 

             </ul> 

        </li>

    </apex:repeat>

</ul></apex:form>

<!-- End of Tree -->      

</apex:page>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

punnoosepunnoose

Same problem there too...

Trre is coming in the same way

Ashish DeoAshish Deo
Bro, same problem I faced, Then I found
1. Static resourse files were not properly placed.
2. Make one zip folder place all the js, css files in it. & then upload that zip file in static resourse.

If still facing problem then provide your mail id, will mail you corretc zip file consting all the files as per your code.
sharath Tsharath T
I'm facing the same problem Ashish Deo as mentioned above this is my code and o/p

VF Page:
<apex:page sidebar="false" controller="treenodes" showheader="false">
<!-- Include the Jquery Script files -->
    <link rel="stylesheet" href="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.treeview.css')}"/>
    <script src="{!URLFOR($Resource.Jtreeview1,'Jquerytreeview/jquery.js')}" type="text/javascript"></script>
    <script src="{!URLFOR($Resource.Jtreeview1,'Jquerytreeview/jquery.cookie.js')}" type="text/javascript"></script>
    <script src="{!URLFOR($Resource.Jtreeview1,'Jquerytreeview/jquery.treeview.js')}" type="text/javascript"></script>
<!-- End of Javascript files -->
<script type="text/javascript">
        
  $(function() {
            $("#tree").treeview({
                collapsed: false,
                animated: "medium",
                control:"#sidetreecontrol",
                persist: "location"
            });
        })
});
  });
</script>
<br/> <br/> <br/>
<!-- Tree -->
<div class="treeheader" style="height:0px;">&nbsp;</div>
<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>
<ul id="tree">
    <apex:repeat value="{!mainnodes}" var="parent">
        <li><strong><apex:outputtext style="color:blue;" escape="false" value="{!parent.gparent.Name}"/></strong>
             <ul>
                 <apex:repeat value="{!parent.parent}" var="child">
                    <li><span class="formattextcon"><apex:outputtext style="color:green;" escape="false" value="{!child.LastName}"/></span>
                        <ul>
                            <apex:repeat value="{!child.Cases}" var="gchildren">
                               <li> <span class="formattextcon"> <apex:outputtext escape="false" style="color:red;" value="{!gchildren.CaseNumber}"/> <b>||</b> &nbsp;<apex:outputtext escape="false" value="{!gchildren.Subject}"/> </span> </li>
                            </apex:repeat>
                        </ul>       
                    </li>
                 </apex:repeat>  
             </ul>  
        </li>
    </apex:repeat>
</ul>
<!-- End of Tree -->       
</apex:page>

Controller:

public class treenodes {

    /* Wrapper class to contain the nodes and their children */
public class cNodes
{

 public List<Contact> parent {get; set;}
 Public Account gparent {get;set;}

 public cNodes(Account  gp, List<Contact> p)
 {
     parent = p;
     gparent = gp;
 }
}
/* end of Wrapper class */ 

Public List<cNodes> hierarchy;

Public List<cNodes> getmainnodes()
{
    hierarchy = new List<cNodes>();
    List<Account> tempparent = [Select Id,Name from Account];
    for (Integer i =0; i< tempparent.size() ; i++)
    {
        List<Contact> tempchildren = [Select Id,FirstName,LastName,(Select Id,CaseNumber,Subject from Cases) from Contact where AccountId = :tempparent[i].Id];
        hierarchy.add(new cNodes(tempparent[i],tempchildren));
     }   
    return hierarchy;
}   
}

My mailID is sharathram02@gmail.com

Output:


My Output file is attached here and I want to display in a tree format with expansion