You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
get Record Id with lightning:Tree
Hi All, I have a requirement to show object's records in nested-accordian view.. It goes Like Customer(Parent) > Customer Product(Child for Customer) > Suites (Child for Customer Product)
Initially I used Accordian, but I was not able to go third-level.. So, I used lightning:tree for this purpose.. But, with this, I cannot get Id of the record.. Can anyone help with this?
CMP:
JS
Vignesh
Initially I used Accordian, but I was not able to go third-level.. So, I used lightning:tree for this purpose.. But, with this, I cannot get Id of the record.. Can anyone help with this?
CMP:
<aura:component controller="TreeController"> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="items" type="Object"/> <lightning:tree items="{! v.items }" onselect="{!c.handleSelect}"/> </aura:component>
JS
({ doInit: function (cmp, event, helper) { var action = cmp.get("c.getTreeData"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { cmp.set('v.items', JSON.parse(response.getReturnValue())); } }); $A.enqueueAction(action); }, handleSelect: function (cmp, event, helper) { var getId = event.getParam('name'); console.log('>>> getName' + getId); }, })
Vignesh
If You Dont Mind Can You Share Your Controller (Apex Class) Cause in mine it Sets Id
All Answers
Try The Below Code Changes By Me Are In Bold Please Let Me Know And Mark It As Best Answer If It Helps
Thank You!
If You Dont Mind Can You Share Your Controller (Apex Class) Cause in mine it Sets Id
FYI - Below is the snippet from code.
cWraper.name = c.Id ; // earlier I had as "c.Name"
cWraper.label =c.Name ;
cWraper.expanded =false ;
Thanks for your help!