I have list of object records displayed in a table on lightning component. I would like to dynamically set a field value when another field value is changed. I should be showing the set value to the User before he clicks on the Submit button.

<td class="mcol3">
  <lightning:inputField onchange="{!c.myChange}" class="{!index}" 
   aura:id="Status" fieldName="Status__c" value="{!recData.Status__c}" />
<td data-label="Close Date" class="mcol6">
 <lightning:inputField aura:id="closeDate" fieldName="Close_Date__c" value=" 
 {!recData.Close_Date__c}" />

Javascript controller:

myChange: function(component, event, helper) { 
    var today = $A.localizationService.formatDate(new Date(), "YYYY-MM-DD");
        var target = event.getSource(); 
        var txtVal = target.get("v.value") ;
   var index =  event.getSource().get("v.class");
        console.log('Selected Value is '+txtVal); 
    //how to set the closeDate value on that row??? 

I am missing on how to set the closeDate value on the same row. Can someone please help?

  • Try get the recData and set the close value there. – Jason Hardy Dec 12 '18 at 19:19

Your Answer

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

Browse other questions tagged or ask your own question.