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 ...
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....
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....
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 (...
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 ...
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">
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.
...
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 ...
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 ...
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">
<...
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 ...
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 ...
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 ...
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}...
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 ...
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>
<...
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" ...
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
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, ...
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}"...
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 ...
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....
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 ...
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 ...
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 ...
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 ...
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}"
...
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 ...
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': '...
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="...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
aura-iteration × 153lightning-aura-components × 121
lightning × 48
aura × 42
aura-if × 13
javascript × 12
aura-attribute × 12
apex × 8
aura-id × 8
iteration × 6
lightning-web-components × 5
lightning-events × 4
javascript-controller × 4
community × 3
lightning-design-system × 3
lightning-datatable × 3
lightning-recordeditform × 3
table × 3
lwc-dom × 3
lightning-inputfield × 3
radio-button × 3
lightning-outputfield × 3
soql × 2
lightning-experience × 2
picklist × 2