0

I have a requirement to display a list of records with a set of fields that can be re-configured, I was able to come up with this piece of code:

<aura:iteration items="{!v.displayDTORecord}" var="item">
<tr class="slds-hint-parent">
    <aura:iteration items="{!item.lstFieldVal}" var="f">
        <aura:if isTrue="{!f.field_api == 'Name'}">
            <td role="gridcell" data-label="{!f.field_api}">
                <div class="slds-truncate" title="{!f.value}">
                    <a href="javascript:void(0);" id="{!item.recId}" onclick="{!c.doRedirect}"><span>{!f.value}</span></a>
                </div>
            </td> 
        <aura:set attribute="else">
            <td role="gridcell" data-label="{!f.field_api}">
                <aura:if isTrue="{!f.field_api != 'Additional_Details__c'}">
                    <aura:if isTrue="{!f.inputField == false}">
                        <div class="no-text-overflow slds-truncate" title="{!f.value}">{!f.value}</div>
                    <aura:set attribute="else">
                        **<lightning:recordEditForm recordId="{!item.recId}" objectApiName="Targeted_Offers__c">
                            <lightning:inputField aura:id="{!f.field_api}" fieldName="{!f.field_api}" />**
                        </lightning:recordEditForm>
                    </aura:set>
                </aura:if>

In a bid to simplify the input field implementation, I used lightning:inputField hoping that it would display properly the picklist fields. Adding to the complexity is the fact that those fields are dependent, and while the controlling picklist is showing properly, when it is updated the dependent picklist stays inactive, is not re-rendering and therefore not displaying the proper subset of values related to the controlling picklist.

I looked it up and while there are a few lightning dependent picklist questions out there, I don't think there's something that accounts for the lightning:inputField being inside an interation. Also, I had an idea of doing a re-render but couldn't really figure out if it'll work. The question here is would there be a workaround to re-render or should I just look at dropping inputField and use a different implementation?

0

This solution will not work, I realised, for two reasons:

  1. lightning:recordEditForm will generate a vertical form for the set of fields that are included in the tags, which will not work in this case and
  2. in order for the dependent picklists to work they have to exist at the same time inside the form tags. It will not work in the iteration and a console error will generate where the dependent picklist will be missing at the time the controlling picklist has resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.