0

I have below an aura component and a controller function, I want to change the value of ui:outputText on change order Price of lightning:input. Now getting the current input box value in the controller.

Aura Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" controller="PricingApprovalQuote">

    <aura:attribute name="InstnceOfLineItem" type="List" />  

    <aura:attribute name = "recordId" type="Id" />
    <aura:attribute name="LYDCNR" type="Double"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="myText" type="decimal"/>

    <aura:iteration items="{!v.InstnceOfLineItem}" var="instance" indexVar="mduindex">
    <div class="c-container">
        <div class="slds-border_bottom" data-index="{!mduIndex}">
                <div class="slds-grid slds-wrap">
                <div class="slds-col slds-size_1-of-1 slds-large-size_8-of-12">
                    <lightning:layout >
                    <lightning:layoutItem padding="around-small">
                    <div class="header-column">
                    <lightning:input name="{!index}" label="Order Price" value = "{!instance.unitprice}" onchange="{! c.orderPriceChange}"/>

                    </div>
                    </lightning:layoutItem>
                    <lightning:layoutItem padding="around-small">
                    <div class="header-column">
                    <lightning:input name="input1" label="Commission" value = ""/>

                    </div>
                    </lightning:layoutItem>
                    </lightning:layout> 
                </div>
                <div class="slds-col slds-size_1-of-1 slds-large-size_4-of-12">
                <lightning:layout >
                <lightning:layoutItem padding="around-small">
                <div class="header-column">
                <p class="field-title" title="DCNR% at Projected cost for(proposed/order price)" style="color: rgb(0, 112, 210);"><b>DCNR% at Projected Cost For<br/> (Proposed/Order Price) </b></p>
                <ui:outputText value="{!instance.DCNRProjectedCost}" />

                </div>
                </lightning:layoutItem>
                </lightning:layout>
                </div>
                </div>
            </div>
    </div>
    </aura:iteration>
    </aura:component>

Controller:

orderPriceChange : function(component, event, helper) {

        var value = event.getSource().get('v.value');
        alert('value '+value);

}
4
  • Use aura id as dynamically <ui:outputText aura:id="text-input-id-1" class="field" value="{!instance.DCNRProjectedCost}"/> Feb 18 '20 at 5:44
  • Thanks Rijwan! But I need outputText value to be change on onChange InputText of order price. how to achieve this?
    – jsmith
    Feb 18 '20 at 5:53
  • 1
    in input name you use aura:id of output text and get in controller and set the output text value with aura id Feb 18 '20 at 6:07
  • 1
    As a side note, you might reconsider using ui:outputText. Salesforce has announced removing support for all ui namespaced components in May, 2021. releasenotes.docs.salesforce.com/en-us/spring20/release-notes/…
    – pchittum
    Feb 18 '20 at 7:33
0

I have done it by following way:

change lightning:input from

To

in component file.

And in controller get the current row and whole array:

orderPriceChange : function(component, event, helper) {

    var value = event.getSource().get('v.name');
    var filteredMdu = component.get("v.InstnceOfLineItem");

    //did some calculation and update array of object

        for (var i in filteredMdu) {

            if (filteredMdu[i].opID == opId) {

                filteredMdu[i].DCNRProjectedCost = ProjectedCost;

                break;
            }
        }
        component.set("v.InstnceOfLineItem",filteredMdu);

}

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.