26 votes
Accepted

How to check List size in aura:iteration

There's a handful of ways, but the most robust would probably be to see if it's not(empty(...)): <aura:if isTrue="{!not(empty(v.opportunityList))}"> ... This will suppress rendering if the ...
sfdcfox's user avatar
  • 481k
9 votes
Accepted

aura:iterate in two columns

lightning:layout is responsive, so you could do something like so: <lightning:layout horizontalAlign="space" verticalAlign="center" multipleRows="true"> <aura:iteration items="{!v....
Lightning Evangelist's user avatar
7 votes

Lightning aura:iteration issue with deleting element after sorting

It definitely seems like a bug in the framework. I don't have any explanation as to why it happens, but I have found it helpful in these cases to "reset" the iteration items before setting them again....
George S.'s user avatar
  • 2,730
6 votes
Accepted

3 nested aura:iteration's don't work properly

Yes, you can nest iterators "infinitely" (up to some really large maximum); it looks like you had an unused value provider name prod in your code. Here's a revised, Short, Self Contained, Correct (...
sfdcfox's user avatar
  • 481k
6 votes
Accepted

component.find an aura:id item created in aura:iteration

aura:id must be a literal value. As such, you can't use an expression in aura:id (it will be treated as literal text). Instead, you can use the element's id via document.getElementById: var ...
sfdcfox's user avatar
  • 481k
6 votes
Accepted

Lightning Components: How to do nested aura:iteration of a list of Accounts with subselected Contacts?

in your second iteration, use {!account.Contacts} instead of {!v.account.Contacts} <aura:iteration items="{!account.Contacts}" var="contact">
Jason Benkert's user avatar
6 votes
Accepted

Is it possible to use the new v41.0 lightning:outputField in huge numbers inside tables? Is it possible to extend it?

Is it possible at all? No. Are Standard Components extensible at all? No. Even if it would be possible, is extension a good idea? It'd be potentially useful, but we can't. ...
sfdcfox's user avatar
  • 481k
6 votes
Accepted

Iterating Complex Map in Lightning

Well Aura:iteration does not support map. Thus you to write your own parser which will convert the Map into a list of custom javascript object that can be iterated by aura: iteration. Assuming this ...
Pranay Jaiswal's user avatar
6 votes
Accepted

how to filter the collection used in aura:iteration

You cannot do this in salesforce lightning - Aura or LWC. Below are the options that works in salesforce lightning Aura Option 1: Have filtered logic in Javascript and use it in Component. This is ...
salesforce-sas's user avatar
5 votes

How do we identify which lightning input is updated in an iteration?

I do not think class attribute should be used to store index. Instead we can use name in Lightning:input to do so. <aura:iteration items="{!v.values2}" var="value" indexVar="index"> <...
Manjot Singh's user avatar
  • 3,408
5 votes
Accepted

Using an aura:iteration index as an array accessor

This kind of question had been asked several times so there are couple answers already, that you might find here: Can I use var[i]? Nope! Are there alternative ways to achieve this? Yes: Create a ...
itsmebasti's user avatar
  • 6,359
5 votes
Accepted

Is it prudent to use force:recordData (and similar) within aura:iteration?

You'll want to look at this answer regarding force:recordData performance, which lightning:recordViewForm depends on. Basically, doing this is going to generate a ton of traffic and perform very ...
sfdcfox's user avatar
  • 481k
5 votes

<aura:if not working but <aura:renderif does - any reason why that you guys can see?

Be careful with cAsE-sEnSiTiViTy: <aura:If isTrue="{!PQs.AnswerID == Dropdown.Listid}"> Is not: <aura:if isTrue="{!PQs.AnswerID == Dropdown.Listid}"> Aside from that, consider using eq ...
sfdcfox's user avatar
  • 481k
4 votes

component.find an aura:id item created in aura:iteration

First problem is that we cannot use expression while assigning aura:id. Aura:id need to be static. so your first change is <a href="javascript:void(0);" role="menuitem" tabindex="-1" id="{!opp.Id}...
Manjot Singh's user avatar
  • 3,408
4 votes

How do we identify which lightning input is updated in an iteration?

This is similar to a previous post. Look at the answer by our team member JF Paradis which throws some light about why event.target is not returning what you expect it to return. This will be fixed in ...
Ravi Jayaramappa's user avatar
4 votes
Accepted

Aura Iterate, get the aura:id of a span

When you're using normal HTML, you have a lot of flexibility in what you do with this. One solution not involving the use of id is to set a data attribute on the span: <aura:component> <...
sfdcfox's user avatar
  • 481k
4 votes
Accepted

aura if comparing iteration variable

Your problem is elsewhere in code you've omitted. Here's a self-contained example of comparing the current iterator to a specified value: <aura:application > <aura:attribute name="items" ...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Lightning aura:iteration issue with deleting element after sorting

Fortuitous timing. We think this was just addressed in a change in framework last week. Change here https://github.com/forcedotcom/aura/commit/b76df7cc31e9bb69425f0a41d4f748ceb6978631
Kris Gray's user avatar
  • 3,106
3 votes
Accepted

Passing an aura:iterated list item to JS controller

I would expect the code to look like this: var comment = component.get("v.AddCommList")[index].Comment__c; component.set('v.commentTooltip', comment.substr(0, 250)); The attribute holds the array, ...
Keith C's user avatar
  • 135k
3 votes
Accepted

Lightning : Select not storing changed data

This is a simple list that is not bound to any particular data. You need to bind it to the value it should represent: <lightning:select aura:id="selectId" value="{!account.Former_Reason__c}"...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Retrieve elements created with Aura:Iteration

This could depend on a lot of things. For example, if your <aura:iteration> is looping over data that you're retrieving via an Apex controller, then the first time it is rendered there will be ...
Aidan's user avatar
  • 13.5k
3 votes
Accepted

JSON parsing and aura iteration in salesforce Lightning

If your Apex class returns the Object in String format, then You Just do JSON.parse("Your_return_String") to get as an Object. EDIT: You have not set Attribute value to 'newassets'.component.set('v....
am_Aravi's user avatar
  • 392
3 votes

Salesforce Lightning: How to save attribute values of a child component in a parent component when a button on the parent component is clicked?

You either want to use an aura:method for this or pass an attribute. I suggest that you read the Lightning Inter-Component Communication Patterns blog post to get an overview of the different ...
POZ's user avatar
  • 4,334
3 votes
Accepted

Iterate related records, display images from string name of contentAsset in Community Cloud

You're on the right track, just missing some pieces to keep moving forward. You'll want to reference an apex controller which helps you with server side actions and surfaces the results to your ...
Stas Christiansen's user avatar
3 votes

Get Task description with line breaks in SOQL

Your thesis is slightly mistaken. Querying Task.Description in SOQL certainly does return line breaks, but they are suppressed in many contexts where you might look for them. You can demonstrate this ...
David Reed's user avatar
  • 92.1k
3 votes
Accepted

Trouble with aura:if

notequals(ofc.agentName, ' ') compares the value to a single space character, ' '. To check if the value is empty, use the empty() function: !empty(ofc.agentName) This will evaluate to true if the ...
David Reed's user avatar
  • 92.1k
3 votes
Accepted

Lightning radio selector in iteration disappears when option selected in another row

You need a unique name for each group: <lightning:radioGroup name="{!'triggerType'+index}" variant="label-hidden" options="{!v.triggerTypeOptions}" ...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Error on second selection for same code in lightning code works fine for first time but second time it gives error

There is a bug in lightning aura conditional rendering aura:if. If you unrender and rerender immediately (i.e., When isTrue condition becomes false and immediately true) then the components do not get ...
salesforce-sas's user avatar
3 votes
Accepted

Radio Button within Iteration - When user selects radiobutton, store the associated sourceId in attribute 'accountId'

component <aura:component> <aura:attribute name="options1" type="List" default="['1','2','3']"/> <aura:attribute name="options" type="List" default="[{'label': '', 'value': '...
User6670's user avatar
  • 2,986
3 votes
Accepted

Selection done in one iteration in aura, is reflecting in every other iteration

I believe your problem is that you are using a "common" variable for all items in your loop, and that when you set the value of those ones, you update them all <c:lwcCustomLookUp objectName="...
Sergio Alcocer's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible