0

Hi Salesforce enthusiasts, I am calling an handler function from the OnChange event of lightning input tag. On the handler, i am trying to assign some value to a @track property which is referred on the for:each iterative to populate the table rows in markup.

My issue is that the @track property does not render as the data on the markup does not change.I have written a validation on the Onchange event handler that will change some value of the @track property.

// JS Handler

updateValues(event){
var foundelement = this.records.find(ele => ele.Id ==  event.target.dataset.id);
if(event.target.name === 'PartNumber'){
        foundelement.Part_Number__c = event.target.value;
    if(!this.isNotFirstTime){
        this.handleIsLoading(true);
        this.records.forEach(res =>{        
      res.Part_Number__c = foundelement.Part_Number__c;
        this.isNotFirstTime=true;
        });
        this.handleIsLoading(false);        
        this.records = [...this.records];      
    }
} 
 <lightning-input 
    type="text" 
    class="fields" 
    variant="label-hidden" 
    label="Approved %" 
    name="Approved" 
    value={obj.Approved} 
    data-id={obj.Id} 
    onchange={updateValues}>
</lightning-input>

Thanks

2
  • Please can anyone share their thoughts Sep 25, 2022 at 6:19
  • Based on your code sample, the HTML added is for element with name Approved and in updateValues the code runs on element with name as PartNumber. So you might need to handle the onchange event also for Approved input? Is that what is missing? Otherwise please edit your question with specific code focussing on the current issue.
    – Raul
    Sep 25, 2022 at 22:32

0

You must log in to answer this question.

Browse other questions tagged .