How to Get Tree View Structure Using Visualforce Page



Here, I mentioned the sample tree structure for a user with a profile using jquery. This is very helpful for the learner in Fieldax&Field Service Management Salesforce.

Visualforce code :-

<apex:page sidebar=”false” controller=”TestTreeView”>

<html>

<head>

</head>

<body>

<script src=”//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js”></script>

<link rel=”stylesheet” href=”//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/themes/default/style.min.css” />

<script src=”//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/jstree.min.js”></script>

<div id=”container”>

<ul>

<li>User

<apex:repeat value=”{!result}” var=”aa”>

<ul><li>{!aa}

<ul><li>{!result[aa]}</li></ul>

</li>

</ul>

</apex:repeat>

</li>

</ul>

</div>

<script>

$(function() {

$(‘#container’).jstree();

});

</script>

</body>

</html>

</apex:page>

Apex Code :-

public class TestTreeView{

public Map<String,Profile> mlis=new Map<String,Profile>();

Public Map<String,String> result{get;set;}

public Map<String,User> mlis1=new Map<String,User>();

//constructor

public TestTreeView(){

result=new Map<String,String>();

for(Profile p:[select name from Profile]){

mlis.put(p.name,p);

}

system.debug(‘cons list’+mlis);

system.debug(mlis.keyset());

for(User u:[select name,profile.name from user where profile.name in : mlis.keyset()]){

system.debug(‘cons list’+u);

result.put(u.name,u.profile.name);

}

system.debug(result);

}

}

We are the ISV Partners and Please reach us for custom development => www.merfantz.com

————————— Feel Happy ———————-


You must be logged into post a comment.