[![enter image description here][1]][1]I have a situation in LWC. In a table there are multiple records coming dynamically with selection of available dropdowns. Each row has Approve and Reject button functionality. I have managed Approve and Reject by a custom field. Here after Approval/Rejection I want to disable buttons for selected approved row only. But because of same disable attribute it disables approve/reject buttons for all unselected rows - that I don't want. I want button disable for only selected row.. Disable attribute in Lightning button for approve/reject is same. disable=(isDisabledButton). How could I achieve this scenario?
HTML CODE
<template for:each={materialMap} for:item="item">
<tr class="slds-hint-parent" key={item.id}>
<td class="slds-cell-wrap" scope="col" >
<div class="slds-truncate slds-cell-wrap">
{item.materialName__c}
</div>
</td>
<td class="slds-cell-wrap" scope="row">
<div class="slds-truncate slds-cell-wrap">
{item.avgCount}
</div>
</td>
<td class="slds-cell-wrap" scope="row">
<div class="slds-truncate slds-cell-wrap">
{item.totalValue}
</div>
</td>
<td class="slds-cell-wrap" scope="row">
<div class="slds-truncate slds-cell-wrap">
{item.discountedValue}
</div>
</td>
<td if:true={showApproveRejectbutton} class="slds-cell-wrap" scope="row">
<div class="slds-truncate slds-cell-wrap">
<lightning-button variant="success" name={item.materialName__c} label="Approve" title="Successful action" onclick={handleApproval} class="slds-m-left_x-small" disabled={isDisabledButton}>
</lightning-button>
</div>
</td>
<td if:true={showApproveRejectbutton} class="slds-cell-wrap" scope="row">
<div class="slds-truncate slds-cell-wrap">
<lightning-button variant="destructive" name={item.materialName__c} label="Reject" title="Destructive action" onclick={handleApproval} class="slds-m-left_x-small" disabled={isDisabledButton}>
</lightning-button>
</div>
</td>
</tr>
</template>
JS
handleApproval(event){
const actionButton = event.target.name;
let selectedButton= event.currentTarget.name;
console.log('selectedButton '+selectedButton);
let objIndx = this.materialMap.findIndex((item => item.materialName__c== selectedButton));
console.log('objIndx== '+objIndx);
let buttonvalue= this.materialMap[objIndx].isDisabledButton=true;
console.log('Name of buttonvalue = '+JSON.stringify(buttonvalue));
}
For this
console.log('Name of buttonvalue = '+JSON.stringify(buttonvalue));
