You need to sign in to do that
Don't have an account?

Not have the clear understaning of JsTee() method and List<JSTreeNode> whats that is it a object or component or what
Could any one suggest that getJsonTree() method calls from where because i have code in which account hierarchy is aleardy diplaying but now i have to associate contact to it.
Code is like this :
so,as per the account code i have created a method which is returning me currentcontact.Now i have to get contact that is for particular account id but i am stuck becuase i dont know from where this getJsonTree() is calling and if yes then how can i associate contact with it.because currently i have created a new method that getJsonNode() but i can use it only when i know that from where exactly its calling.could anybody help me on this.
@description This is the controller class for HierarchyTree component public without sharing class HierarchyTree { public static String currentId {get; set;} private static Account currentAccount { get { if (currentAccount == null) { currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId]; } return currentAccount; } private set; } private static Contact currentContact { get { if (currentContact == null) { currentContact = [select Id From Contact where AccountId = :currentId]; } return currentContact; } private set; } private static Account ultimateParentAccount { get { if (ultimateParentAccount == null) { if (currentAccount.UltimateParent__c != null) { ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c]; } else { ultimateParentAccount = currentAccount; } } return ultimateParentAccount; } private set; } /** * @description This methos is used to generate JSON data for jsTree component */ public static String getJsonTree() { List<JSTreeNode> listItems = new List<JSTreeNode>(); listItems.add( new JSTreeNode( ultimateParentAccount.Id, '#', ultimateParentAccount.Name, new JSTreeNodeState(true, false, false), new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '') ) ); public String getJsonNode() { List<JSTreeLeave> listConItems = new List<JSTreeLeave>(); listConItems.add( new JSTreeLeave( currentContact.Id, '#', currentContact.Name, new JSTreeNodeState(true, false, false), new JSTreeNodeAAttr(String.valueOf(IdCon.Id) == currentId ? 'font-weight:bold' : '') ) ); for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) { listItems.add( new JSTreeNode( acc.Id, acc.ParentId, acc.Name, new JSTreeNodeState(true, false, false), new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '') ) ); } return JSON.serialize(listItems); } for (Contact con : AccountServices.getAllContact(new List<Contact>{Id})) { listConItems.add( new JSTreeNode( con.Id, con.AccountId, con.Name, new JSTreeNodeState(true, false, false), new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '') ) ); } return JSON.serialize(listConItems); } /** * This class is used to generate jsTree node */ @TestVisible private class JSTreeNode { public String id; //required public String parent; //required public String text; // node text public String icon; // string for custom icon public JSTreeNodeState state; // instance of JSTreeNodeState public Object li_attr; // attributes for the generated LI node public JSTreeNodeAAttr a_attr; // attributes for the generated A node public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) { this.id = id; this.parent = parent; this.text = text; this.state = state; this.a_attr = a_attr; } } @TestVisible private class JSTreeNodeState { public Boolean opened; // is the node open public Boolean disabled; // is the node disabled public Boolean selected; // is the node selected public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) { this.opened = opened; this.disabled = disabled; this.selected = selected; } } @TestVisible private class JSTreeNodeAAttr { public String style; // style of current node public JSTreeNodeAAttr(String style) { this.style = style; } } }
Code is like this :
so,as per the account code i have created a method which is returning me currentcontact.Now i have to get contact that is for particular account id but i am stuck becuase i dont know from where this getJsonTree() is calling and if yes then how can i associate contact with it.because currently i have created a new method that getJsonNode() but i can use it only when i know that from where exactly its calling.could anybody help me on this.