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

Conditionally Displaying Lightning Tab
I am implementing lightning:tabset and lightning:tab to display tabs in a lightning component -- I am trying to conditionally display one particular tab based on a value returned by the controller -- but it is not rendering the tab. Does anyone have any insight into how to achieve this functionality? Also, when I try to set the selectedTabId in the init function, I get an error saying the tab does not exist.
Controller:
Controller:
({ doInit : function(component, event, helper) { var action = component.get("c.getSearchFromId"); action.setParams({ "recordId": component.get("v.recordId") }); action.setCallback(this, function(response) { var state = response.getState(); if(state === "SUCCESS"){ if(response.getReturnValue().Candidates_Visible__c == true){ component.set('v.displayCandidates',true); } else { component.set('v.displayCandidates',false); } component.set('v.search',response.getReturnValue()); } }); $A.enqueueAction(action); } })Component:
<aura:component controller="SecureSiteController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" > <ltng:require styles="/resource/slds_2_1_3/assets/styles/salesforce-lightning-design-system-vf.css" /> <aura:attribute name="recordId" type="String" access="global" /> <aura:attribute name="search" type="Search__c" access="global" /> <aura:attribute name="displayCandidates" type="Boolean" default="false" /> <aura:handler name="init" value="{!this}" action="{!c.doInit}" access="global" /> <!-- Display secure site tabs --> <lightning:tabset variant="default" selectedTabId="{!v.selTabId}"> <aura:if isTrue="{!v.displayCandidates == true}"> <lightning:tab aura:id="candidates" tabindex="1" id="candidates" title="Candidates" label="Candidates"> <c:CandidateViewer recordId="{!v.recordId}" /> </lightning:tab> </aura:if> <lightning:tab aura:id="searchmaterials" tabindex="2" id="searchmaterials" title="Search Materials" label="Search Materials"> <c:SearchMaterials recordId="{!v.recordId}" /> </lightning:tab> <lightning:tab aura:id="keydates" tabindex="3" id="keydates" title="Key Dates" label="Key Dates"> <c:SearchKeyDates recordId="{!v.recordId}" /> </lightning:tab> <lightning:tab aura:id="consultants" tabindex="4" id="consultants" title="Consultants" label="Consultants"> <c:SearchConsultants recordId="{!v.recordId}" /> </lightning:tab> <lightning:tab aura:id="securemessage" tabindex="5" id="securemessage" title="Send a Message" label="Send a Message"> <c:SecureSiteMessage recordId="{!v.recordId}" /> </lightning:tab> </lightning:tabset> </aura:component>
<aura:if isTrue="{!v.displayCandidates}">
can you try changing your if condition to following?
if(response.getReturnValue()[0].Candidates_Visible__c == true)
Gets rendered just fine toggling displayCandidates on and off.
@Abhishek Sagar 1