How to iterate over SObject list returned from server side controller in Lightning Component using <aura:iteration>
to show the field values in table using dot notation.I am asking for passing field names dynamically with dot notation.
Some are marking it as duplicate, which is not. It may be possible that these guys are not getting it correctly or don't have solution to it. So please read it again to understand the problem, what I am asking. It is totally different.
Attributes I have used
<aura:attribute name="records" type="Object[]"/> **This contains sObject records**
<aura:attribute name="fieldsAPI" type="String[]"/> **Selected fields API names**
<aura:attribute name="fieldsName" type="String[]"/> **Selected fields label Names**
Here is what I have tried and done so far : My Record Area
<table class="slds-table slds-table--bordered slds-no-row-hover slds-table--cell-buffer">
<thead>
<tr class="slds-text-title--caps">
<aura:iteration items="{!v.fieldsName}" var="fieldName">
<th scope="col">
<div class="slds-truncate" title="{!fieldName}">{!fieldName}</div>
</th>
</aura:iteration>
</tr>
</thead>
<tbody id="data">
<aura:iteration items="{!v.records}" var="record">
<tr class="slds-hint-parent">
<aura:iteration items="{!v.fieldsAPI}" var="fieldAPI">
<td>
<div class="slds-truncate" title="{!fieldAPI}">{!record.fieldAPI}</div>
</td>
</aura:iteration>
</tr>
</aura:iteration>
</tbody>
</table>
If I replace {!record.fieldAPI}
with literal like {!record.Name}
it gives what I required, but I want it dynamically here, without javascript way to create it there and append where I want.