function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sumit Budhiraja 9133Sumit Budhiraja 9133 

Force:inputfield doesn't render lookup value when used with wrapper in lightning?

I am rendering Accounts with their contacts in lightning component and showing account lookup field on child contacts But account lookup is not coming using force:inputfield in the contact section. However, when I  printed the accountid on page, it's coming but lookup not rendering.

Please help and find the below code!
<aura:component controller="Account_with_contacts_controller" implements="force:appHostable,flexipage:availableForAllPageTypes">    
    <aura:attribute name="listaccount" type="Account_with_contacts_controller.Wrapper_Account[]"/>    
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
   <aura:attribute name="contact" type="Contact" 
               default="{ 'sobjectType': 'Contact' }"/>
    <div class="slds-grid slds-m-around--medium ">
        <table class="slds-table slds-table--bordered slds-max-medium-table--stacked">
            <thead>
                <tr class="slds-text-heading--label">
                     <th scope="col"> </th>
                    <th scope="col">ID </th>
                    <th scope="col">Name</th>
                    <th scope="col">Phone</th>
                    <th scope="col">Billing City</th>

                </tr>
            </thead>
            <tbody>
                <aura:renderIf isTrue="{!v.listaccount.length!=0}">
                <aura:iteration items="{!v.listaccount}" var="item" indexVar="i">
                    <tr>
                        <td>
                          
                        </td>                           
                         <td>
                            <label class="slds-checkbox">
                                <ui:inputCheckbox class="selector" aura:id="{!i}" value="{!item.selected}" change="{!c.selectcheckbox}"/>
                                <span class="slds-checkbox--faux"></span>
                            </label>
                        </td>   
                        <td><ui:inputtext class="field" value="{!item.Name}"/></td>
                        
                        <td><ui:inputtext class="field" value="{!item.Phone}"/></td>
                        <td><ui:inputtext class="field" value="{!item.BillingCity}"/></td>
                         <aura:iteration items="{!item.Contacts}" var="contactitem" indexVar="j">
                          
                    <tr>
                        <td>
                          
                        </td>                           
                            
                        <td><ui:inputtext class="field" label="name" value="{!contactitem.Name}"/></td>
                        <td width="50%">{!contactitem.AccountId}<force:inputField value="{!contactitem.AccountId}"/> </td>
                        <td><ui:inputtext class="field" label="phone" value="{!contactitem.Phone}"/></td>
                        <td><ui:inputtext class="field" value="{!contactitem.Description}"/></td>
                        
                    </tr>      
                </aura:iteration> 
                    </tr>      
                </aura:iteration> 
                </aura:renderIf>
            </tbody>
        </table> 
    </div>
    
        <div>
        <button    style="float:centre" class="slds-button slds-button--brand slds-m-bottom--large slds-align--absolute-center btn-lg" onclick="{!c.UpdateAccounts}">Update Accounts</button>
        <br/>    
           </div>
</aura:component>
sfdcMonkey.comsfdcMonkey.com
hi sumit,
The default Salesforce components do not support lookup, you have to build your custom component. However you can reuse code from here,
http://www.sfdcmonkey.com/2017/07/17/re-usable-custom-lookup/
i hope it helps you.
  Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 
Sumit Budhiraja 9133Sumit Budhiraja 9133
Thanks for replying! Yes, I know that with default components lookup doesn't support. In my case, If you see i am using,<td width="50%">{!contactitem.AccountId}<force:inputField value="{!contactitem.AccountId}"/> </td>   force:inputfield which we can use to render as lookup.

I have created one below component in past which is rendering lookup and it's working fine.
<aura:component controller="ContactController">
    <aura:attribute name="contact" type="Contact" 
               default="{ 'sobjectType': 'Contact' }"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div aura:id="lookup-pill" class="slds-pill-container">
                    <span class="slds-pill" style="width:100%">

               <div class="slds"> <force:inputField aura:id="contactName" class="slds-select"
                                 value="{!v.contact.AccountId}"/> </div>
    </span>
    </div>

</aura:component>


So the same thing I am using in my affected component but it's not working with the wrapper?