You need to sign in to do that
Don't have an account?

Nested iterations
Hi,
I have a nested aura:iteration like this:
<aura:iteration items="{!v.results}" var="res">
<tr class="slds-hint-parent">
<aura:iteration items="{!v.ColumnsNameArr}" var="colName">
<td>
<div class="slds-truncate" ><a href="javascript:void(0);">{!res[colName]}}</a></div>
</td>
</aura:iteration>
</tr>
</aura:iteration>
How can I write correct {!res[colName]}? It is possible to do something like this in lightning?
Thank you.
I have a nested aura:iteration like this:
<aura:iteration items="{!v.results}" var="res">
<tr class="slds-hint-parent">
<aura:iteration items="{!v.ColumnsNameArr}" var="colName">
<td>
<div class="slds-truncate" ><a href="javascript:void(0);">{!res[colName]}}</a></div>
</td>
</aura:iteration>
</tr>
</aura:iteration>
How can I write correct {!res[colName]}? It is possible to do something like this in lightning?
Thank you.
<aura:attribute name="ColumnsNameArr" type="String[]" />
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var resp = response.getReturnValue();
component.set('v.results', resp);
}
});
and I have data in resp.
ColumnsNameArr is different defined...I have in design file a text input....and I insert there the object fields I want to be displayed separated by comma. In js Controller I get the fields using split(',') and trim() and insert them in ColumnsNameArr .
var columnsName = component.get('v.tableColumnsName'); //tableColumnsName is the attribut in both files (design and component)
columnsNameArr = columnsName.split(',');
columnsNameArr = columnsNameArr.map(function(str) { return str.trim(); });
component.set('v.ColumnsNameArr', columnsNameArr);
https://www.codengine.in/2019/07/nested-iteration-salesforce-lightning-aura-components.html