You need to sign in to do that
Don't have an account?

Update Table values based on user Inputs in LWC
Hello Everyone,
I need your help, I am trying to fetch data from a apex class and store it in a list. The list basically has a custom object data. now when i render it in a table and show in the html , i display the values in a table and use input fields to show. Now when i change the values from the front end it does not stores in the track variable. I know there should be some java script magic, can you help to figure out what ?
HTML:
<template for:each={budgetData} for:item="budget">
<tr key={budget.Id} class="slds-hint-parent">
<td >
<div class=" headingBG" >{budget.BG_Code__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.BG_Name__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.Category_Code__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.Category_Name__c}</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" id={budget.Id} name={budget.Upselling_Investment__c} value={budget.Upselling_Investment__c} disabled={disableFieldBudget} onchange={onchangevalues} >
</lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Retailer_promotion_STTI__c} disabled= {disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Consumer_promotion__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Brand_investment__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Cooperative_advertising_KAM__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
So when the value which comes is a list and i store it in a track. Now when i want to update i should call a onchange method may be.
I need your help, I am trying to fetch data from a apex class and store it in a list. The list basically has a custom object data. now when i render it in a table and show in the html , i display the values in a table and use input fields to show. Now when i change the values from the front end it does not stores in the track variable. I know there should be some java script magic, can you help to figure out what ?
HTML:
<template for:each={budgetData} for:item="budget">
<tr key={budget.Id} class="slds-hint-parent">
<td >
<div class=" headingBG" >{budget.BG_Code__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.BG_Name__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.Category_Code__c}</div>
</td>
<td >
<div class=" headingBG" >{budget.Category_Name__c}</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" id={budget.Id} name={budget.Upselling_Investment__c} value={budget.Upselling_Investment__c} disabled={disableFieldBudget} onchange={onchangevalues} >
</lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Retailer_promotion_STTI__c} disabled= {disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Consumer_promotion__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Brand_investment__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
<td >
<div class="slds-truncate" >
<lightning-input type="text" value={budget.Cooperative_advertising_KAM__c} disabled={disableFieldBudget} ></lightning-input>
</div>
</td>
So when the value which comes is a list and i store it in a track. Now when i want to update i should call a onchange method may be.
Please go through the Lighting Web Component developer guide to create the table with Onchange functionality.
Here is the link to learn the LWC,
https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/example
Thanks,
SEKAR RAJ
Did you find any solution regarding this?
Thanks
Saransh