You need to sign in to do that
Don't have an account?
Vinnie Bacon 20
How do you simply set an attribute based on aura:if?
I'm trying to do something I assume is pretty simple but am getting stumped on how to do it in Lightning. MY pseudocode is:
<aura:attribute name="printedSpecialRow" type="Boolean" default="false" />
<aura:iteration items="{!v.myList}" var="anItem">
<aura:if isTrue="{!!v.printedSpecialRow}">
<tr>Print Special Row</tr>
<!-- Now set the value of printedSpecialRow to true -->
</aura:if>
</aura:iteration>
I have simple controller method that sets the printedSpecialRow value to true. That's easy enough. But how do I call this method from within the aura:if block to set the value so the next iteration will not call the aura:if block.
This has gotta be easy right. :) Thanks!
<aura:attribute name="printedSpecialRow" type="Boolean" default="false" />
<aura:iteration items="{!v.myList}" var="anItem">
<aura:if isTrue="{!!v.printedSpecialRow}">
<tr>Print Special Row</tr>
<!-- Now set the value of printedSpecialRow to true -->
</aura:if>
</aura:iteration>
I have simple controller method that sets the printedSpecialRow value to true. That's easy enough. But how do I call this method from within the aura:if block to set the value so the next iteration will not call the aura:if block.
This has gotta be easy right. :) Thanks!
You can use the below way to achieve this:
<aura:attribute name="printedSpecialRow" type="Integer" default="1"/>
<aura:iteration items="{!v.myList}" var="anItem" indexVar="idx">
<aura:if isTrue="{!lessthan(idx,v.printedSpecialRow)}">
<tr>Print Special Row</tr>
</aura:if>
</aura:iteration>
You can also use the below method:
https://salesforce.stackexchange.com/questions/205704/using-auraif-inside-the-auraiteration
https://salesforce.stackexchange.com/questions/138760/is-there-a-salesforce-solution-to-filter-or-limit-aura-iteration
Thanks,
Maharajan.C
I decided that the best approach was to have each group be its own component. I can grab all 20 or so items in one query. Then create the five sub-lists I need from those. For each sub-list I create the component which has a header and its list of items.
I remember hearing that modularization of components was the best way to use Lightning. Time to put that into practice. :)