Last active
February 17, 2021 22:52
-
-
Save surajp/93235ef5a4ab7f6d28268e91ba8a8b3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template for:each="{forecastRevenues}" for:item="period"> | |
<tr key="{period.index}"> | |
<td | |
data-label="{period}" | |
data-id="{period.Id}" | |
data-field="Forcast_Period_Start__c" | |
> | |
<div class="slds-truncate" title="{period.Forecast_Period_Start__c}"> | |
<lightning-input | |
type="date" | |
name="input2" | |
label="Period start date" | |
value="{period.Forecast_Period_Start__c}" | |
onchange="{handleChange}" | |
> | |
</lightning-input> | |
</div> | |
</td> | |
<td | |
data-label="{period}" | |
key="{period.index}" | |
data-id="{period.Id}" | |
data-field="Forecasted_Days__c" | |
> | |
<div class="slds-truncate" title="{period.Forecasted_Days__c}"> | |
<lightning-input | |
type="number" | |
name="Forecasted_Days__c" | |
label="Number of days" | |
value="{period.Forecasted_Days__c}" | |
onchange="{handleChange}" | |
> | |
</lightning-input> | |
</div> | |
</td> | |
</tr> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleChange(event){ | |
const currentRecordId = event.target.closest('td').dataset.id; | |
const fieldName = event.target.closest('td').dataset.field; | |
this.forecastRevenues = | |
this.forecastRevenues.map(r=>{ | |
if(r.Id===currentRecordId){ | |
r[fieldName] = event.detail.value; | |
} | |
return r; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment