You need to sign in to do that
Don't have an account?
Dharmesh Jagetia 7
I want to iterate this table dynamically rather than hardcode on lightning component to take input in lookup field
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="contact1" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact2" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact3" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact4" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
<thead>
<tr class="slds-text-heading_label">
<th scope="col"><div class="slds-truncate" title="number"></div></th>
<th scope="col"><div class="slds-truncate" title="ID">NAme</div></th>
<th scope="col"><div class="slds-truncate" title="Name">Lst anesdjsalk</div></th>
<th scope="col"><div class="slds-truncate" title="Type">lksdnasdkjds</div></th>
</tr>
</thead>
<table>
<tr>
<td>
<force:inputField value="{!v.contact1.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact1.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact1.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact2.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact2.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact2.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact3.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact3.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact3.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact4.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact4.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact4.Email}"/>
</td>
</tr>
</table>
</table>
<lightning:button type="submit" label="NDC Verify" class="slds-float--right">
</lightning:button>
</aura:component>
<aura:attribute name="contact1" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact2" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact3" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<aura:attribute name="contact4" type="Contact"
default="{ 'sobjectType': 'Contact' }"/>
<table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
<thead>
<tr class="slds-text-heading_label">
<th scope="col"><div class="slds-truncate" title="number"></div></th>
<th scope="col"><div class="slds-truncate" title="ID">NAme</div></th>
<th scope="col"><div class="slds-truncate" title="Name">Lst anesdjsalk</div></th>
<th scope="col"><div class="slds-truncate" title="Type">lksdnasdkjds</div></th>
</tr>
</thead>
<table>
<tr>
<td>
<force:inputField value="{!v.contact1.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact1.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact1.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact2.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact2.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact2.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact3.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact3.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact3.Email}"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<force:inputField value="{!v.contact4.LastName}"/>
</td>
<td>
<force:inputField value="{!v.contact4.AccountId}"/>
</td>
<td>
<force:inputField value="{!v.contact4.Email}"/>
</td>
</tr>
</table>
</table>
<lightning:button type="submit" label="NDC Verify" class="slds-float--right">
</lightning:button>
</aura:component>
you can use 1 attribute for list of contacts in place of 4 attributes for 4 Contacts. Then further you can use iteration.
<aura:attribute name="contacts" type="Contact[]" />
If you have further query, please let me know.
-Manish