0
        <template for:each={recenttimesheet} for:item="tts">
            <tr key={tts.Id}>
                <td><lightning-input type="radio" name="radioButtonSelect" value={tts.Id} onclick={handleChangeRadio} id={tts}></lightning-input></td>
                <td>{tts.Name}</td>
                <td onchange={handleStatusChange}>{tts.Status__c}</td>
                <td>{tts.Week_Start_Date__c}</td>
                <td>{tts.Week_End_Date__c}</td>    
                <td>{tts.Total_Hours_Logged__c}</td> 
                <td>  <!-- <template if:true={disabledbtn}> --> if i'm putting this then the Submit Button is enable or disable for all record not for one record
                  <lightning-button variant="brand" label="Submit" disabled={disablebtn}></lightning-button> 
                                        <!--   </template> --> </td>
                               
            </tr>
        </template>

image---- enter image description here

11
  • 1
    You need that disabled option to be part of the JavaScript object data you are iterating.
    – Phil W
    Commented Oct 17, 2022 at 12:40
  • @PhilW yes i mention in js disablebtn but it is hiding for all record and also if we give this false then it is showing for all record Commented Oct 17, 2022 at 12:56
  • That's my point: the flag needs to be part of the iterated data, not a standalone flag. You need this boolean value in your "tts" item.
    – Phil W
    Commented Oct 17, 2022 at 12:58
  • can you tell me how? Commented Oct 17, 2022 at 13:01
  • Phil already did; you need to put the flag into each item in the array, and use {tts.disablebtn} instead.
    – sfdcfox
    Commented Oct 17, 2022 at 13:18

1 Answer 1

4
<template for:each={data} for:item="tts">
    <tr key={tts.Id}>
        <td><lightning-input type="radio" name="radioButtonSelect" value={tts.Id} onclick={handleChangeRadio} id={tts}></lightning-input></td>
        <td>{tts.Name}</td>
        <td onchange={handleStatusChange}>{tts.Status__c}</td>
        <td>{tts.Week_Start_Date__c}</td>
        <td>{tts.Week_End_Date__c}</td>    
        <td>{tts.Total_Hours_Logged__c}</td> 
        <td>  
            <lightning-button if:true={tts.showSubmitBtn} variant="brand" label="Submit" disabled={disablebtn}></lightning-button> 
        </td>        
    </tr>
</template>

before populating recenttimesheet list do this manipulation

this.data = [];
this.data = recenttimesheet.map(item =>{
    let showSubmitBtn = item.Status__c == 'Open'
    return {...item, 
        "showSubmitBtn":showSubmitBtn,
    }
})

FR : Demo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .