function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Atul SinghAtul Singh 

Expandable section Problem In Lightning

<!---Component--->
<div class="slds-p-around--large">
        <aura:iteration items="{!v.CommunicatoActivity}" var="Act" indexVar="i">
            <div class="slds-page-header" aura:id="{!i+'activity'}" style="cursor: pointer;" onclick="{!c.sectionOne}">
                <section class="slds-clearfix" >
                    <div class="slds-float--left ">
                        <lightning:icon class="slds-show" aura:id="articleOne" iconName="utility:chevronright" size="xx-small" alternativeText="Indicates add"/>&nbsp;&nbsp;
                        <lightning:icon class="slds-hide" aura:id="articleOne" iconName="utility:chevrondown" size="xx-small" alternativeText="Indicates dash"/>&nbsp;&nbsp;
                    </div>
                    
                    <div class='msgContainer'>
                        <aura:if isTrue="{!v.CommunicatoActivity.Type__c == 'Incoming'}">
                            <div class="iconContainer"><img src="{!$Resource.incomingSMS}" height="20" width="20" /></div>
                            <aura:set attribute="else">
                                <div class="iconContainer"> <img src="{!$Resource.outgoingSMS}" height="20" width="20"  /></div>
                            </aura:set>
                        </aura:if>&nbsp;&nbsp;
                        <div class="numberContainer" ><a>{!Act.Phone_Number__c}</a></div>
                        <div style="margin-left: 15%;">
                            <p>You Sent a Message</p>
                        </div>
                    </div>
                </section>
            </div>
            <div class="slds-hide slds-p-around--medium" aura:id="articleOne">
                <p><strong>Type:</strong>{!Act.Type__c}</p>
                <p><strong>Phone:</strong>{!Act.Phone_Number__c}</p>
                <p><strong>Message:</strong>{!Act.Message__c}</p>
            </div>
        </aura:iteration>
    </div>

<!------------Js----------->
doInit : function(component, event, helper) {
        var action = component.get('c.getCommunicatoActivity');
        action.setParams({ "recordId" : component.get("v.recordId") });
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state ==='SUCCESS'){
                component.set('v.CommunicatoActivity',response.getReturnValue());
            }else{
                console.log('Some Error');
            }
        });
        $A.enqueueAction(action);
        
    },
    
    sectionOne : function(component, event, helper) {
       helper.helperFun(component,event,'articleOne');
    },

<!-------Helper.Js---------------------->
helperFun : function(component,event,secId) {
      var acc = component.find(secId);
            for(var cmp in acc) {
            $A.util.toggleClass(acc[cmp], 'slds-show');  
            $A.util.toggleClass(acc[cmp], 'slds-hide');  
       }
    }

This is my code for expandable section in lightning component i get using aura:iteration
My problem is when i click on single section all section is exapanded 
Vinod Kumar 352Vinod Kumar 352
Hi Atul Singh,
Did you find the solution? Currently I am facing the same problem in one of my requirement. 
TIA.
Balasubramaniam 07Balasubramaniam 07
Hi,
aura:id doesn't support expressions. You can only assign literal string values to aura:id.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_ids.htm

You can use normal html id attribute and use the same to toggle the class

Thanks,
BaLa
S_RathS_Rath
Hi,

You cannot use aura:id for this as it can take string values only as your sections are getting created dynamically so you can create the dynamic classes or id and can hide or show your component on the basis of that.

Hope, this will help you!!

Thanks