function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Avik Mukherjee 16Avik Mukherjee 16 

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.

 
SEKAR RAJ.SEKAR RAJ.
Hi Avik,
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
 
Saransh SrivastavaSaransh Srivastava
Hi Avik,
Did you find any solution regarding this?

Thanks
Saransh