I am facing problem in rerendering the treepanel when I select value from selectlist.The jsonstring in the controller is right but it is not reflecting in jstree.

Below is the code. Please help on how to fix this.

 <apex:page controller="customcontroller" sidebar="false" id="page">

        <apex:includeScript value="{!$Resource.jquerymin}"/>
        <apex:stylesheet value="{!URLFOR($Resource.jstree, '/jstree/dist/themes/default/style.min.css')}"/>
        <script src="{!URLFOR($Resource.jstree, '/jstree/dist/jstree.min.js')}"></script>
        <apex:stylesheet value="{!$Resource.AlignmaxCommonCSS}"/>
        $( document ).ready(function() {
            function createTree(){
                var j$=jQuery.noConflict();

                        "core" : {
                        "check_callback" : true,
                        "themes" : { "stripes" : true },        
                        'data' : {!jsonString}


                alert('inside tree Json String'+JSON.stringify({!jsonString}));
        <apex:form id="form">
          <div class="box-main">

            <div class="box-content">
                <apex:actionStatus startText=" (Shant Baitho...!!!)" stopText="" id="processingStatus" />
                <apex:actionFunction name="TreeRefresh"   status="processingStatus" action="{!processTeam}"  rerender="treePanel" />
                <apex:selectList value="{!selectedTeam}" size="1" style="width:20%;" onchange="TreeRefresh();" >
                    <apex:selectOptions value="{!TeamList}"></apex:selectOptions>
                <div class="tree">
                    Tree Structure 
                    <apex:outputPanel id="treePanel">
                        <div id="jstree"> </div>  


Controller Code

public class Customcontroller{
    public String jsonString{get;set;}
    public String rootGeographyId {get; set;} 
    public static String selectedTeam{get;set;}
    public Customcontroller()
        rootGeographyId = [ Select Id From Territory__c where name= 'D' ].Id ;
        jsonString = GeographyUtilForAcco.getTreeJSON(rootGeographyId,selectedTeam);  
        system.debug('--JSON String in Alignmax Constructor---'+jsonString);  
    public List<SelectOption> getTeamList(){
        List<SelectOption> tList = new List<SelectOption>();
        tList.add(new SelectOption('Select Team','Select Team'));
        for(Team__c t : [Select Name from Team__c])
            tList.add(new SelectOption(t.Name,t.Name));
        return tList;
    public void processTeam()
        jsonString = GeographyUtilForAcco.getTreeJSON(rootGeographyId,selectedTeam);
        system.debug('--JSON String in Alignmax Controller---'+jsonString);  
  • It would help if you posted your relevant controller code, or at least processTeam()
    – Rob
    Sep 29 '15 at 8:14
  • 1
    Where is your reRender tag? Sep 29 '15 at 9:04
  • Added the controller and rerender tag
    – Arun SFDC
    Sep 29 '15 at 10:41

You're rerendering the panel but not updating the tree. Try adding createTree() as the oncomplete attribute of the actionFunction

<apex:actionFunction name="TreeRefresh" status="processingStatus" action="{!processTeam}" rerender="treePanel" oncomplete="createTree()" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.