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
vibrationvibration 

problem in tree view

Hi all,

  I have some problem in treeview. script and java query is not working .plz correct the code.

 

 

 

 

plugin Download : http://bassistance.de/jquery-plugins/jquery-plugin-treeview/

 

Reference Code :http://www.forcetree.com/2011/04/tree-view-in-visualforce-page.html

 

plugin used :Jquerytreeview

 

 

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.Jtreeview,'Jquerytreeview/lib/jquery.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/lib/jquery.cookie.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'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>

 

 

class:

 

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;
}
}

 

please help me

Andy BoettcherAndy Boettcher

What error messages are you getting?  What exactly is not working?

Chamil MadusankaChamil Madusanka

Replace your script with following script

 

<script>
  $(document).ready(function(){
    $("#tree").treeview({
		collapsed: false,
		animated: "medium",
		control:"#sidetreecontrol",
		persist: "location"
});
  });
  </script>

 

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

Suman KunduSuman Kundu

I think you have downloaded the zip file file from plugin download link, and created a static resource with name: "Jtreeview".

If I am right, then what I think you to do is use the following code:

<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>

 

instead of

 

<link rel="stylesheet" href="{!URLFOR($Resource.Jtreeview,'Jquerytreeview

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