Thursday, November 1, 2018

Lightning:treegrid - Displaying Account hierarchy using treegrid

Salesforce has introduced new tag called lightning:treegrid which can be used to display tree structure in tabular form. Lightning:tree can be used to display the hierarchy but if you want to display additional information then lightning:treegrid becomes useful.

If you want to lean how to use lightning:tree tag to display hierarchy for any record then refer below URL:

Lightning Tree : Generic Lightning Component to Display Hierarchy for any sObject

If you have to display account hierarchy along with another fields information as displayed in below image, then use treegrid.


Below is complete code to display account hierarchy. Just pass account record Id and lightning component will display complete hierarchy.


Hope this help!!!

10 comments:

  1. you people are really great ,i am getting the ERROR in the following lines.please help.
    component.set("v.gridData", roles[undefined]._children);
    console.log('*******treegrid data:'+JSON.stringify(roles[undefined]._children));

    ReplyDelete
  2. you people are really great ,i am getting the ERROR in the following lines.please help.
    component.set("v.gridData", roles[undefined]._children);
    console.log('*******treegrid data:'+JSON.stringify(roles[undefined]._children));

    ReplyDelete
  3. This page has an error. You might just need to refresh it.
    Error in $A.getCallback() [Cannot read property 'config' of undefined]
    Callback failed: apex://SK_AccountTreeGridCmpController/ACTION$findHierarchyData
    Failing descriptor: {c:SK_AccountTreeGridCmp}

    ReplyDelete
    Replies
    1. Hi,

      Can you please code to call this component. I just wanted to know what all parameters you are passing to this component.

      Thanks

      Delete
    2. I call the component by below code:






      Delete
  4. Can you please help load asynchronous on tree grid.

    ReplyDelete
  5. This works as a pro Awesome Site.

    ReplyDelete