1

Hi I want to display data in stacked form i.e one after the other in 2 coloumn format. I am using below code for that. But I am getting spaces between the data as shown in attachment;enter image description here if data is more in one component and less in another.

 <lightning:layout multipleRows="true">
       <aura:iteration items="{!v.body}" var="test">
           <lightning:layoutItem size="6" smallDeviceSize="12" mediumDeviceSize="6">
               {!test}
           </lightning:layoutItem>
       </aura:iteration>
   </lightning:layout>
3

That's how an SLDS grid (lightning:layout) works. If you want to have them immediately below each other, you'd have to make a left grid and right grid:

<lightning:layout multipleRows="true">
    <lightning:layoutItem size="6">
        <lightning:layout multipleRows="true">
            <aura:iteration items="{!v.body}" indexVar="leftIndex" var="test">
                <aura:if isTrue="{!mod(leftIndex,2)==0}">
                    <lightning:layoutItem size="12">
                        {!test}
                    </lightning:layoutItem>
                </aura:if>
            </aura:iteration>
        </lightning:layout>
    </lightning:layoutItem>
    <lightning:layoutItem size="6">
        <lightning:layout multipleRows="true">
            <aura:iteration items="{!v.body}" indexVar="rightIndex" var="test">
                <aura:if isTrue="{!mod(rightIndex,2)==1}">
                    <lightning:layoutItem size="12">
                        {!test}
                    </lightning:layoutItem>
                </aura:if>
            </aura:iteration>
        </lightning:layout>
    </lightning:layoutItem>
</lightning:layout> 
  • Thanks for your answer, but it did not work@sfdcfox – Akhil Dec 14 '17 at 6:48
  • @Akhil I had to fiddle with the syntax, and I have this working in my developer org. Try the newer version. – sfdcfox Dec 14 '17 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.