Skip to main content

#Table Component0 人がディスカッション中

need to get the id from key field of lwc tableScreenshot 2023-02-17 010208.png

Hi, I'm using html table not standard data table now I want to edit record and for that i need need recordId using onclick in to pass into lightning-record-edit-from so how I will get the id. and If I'm wrong please tell me how I will do it.

Thanks in advance.

#LWC  #Table Component #Javascript Code #Salesforce Developer #Trailblazers #TrailblazerCommunity

1 件の回答
  1. 2023年2月16日 20:23

    Hi @Rashid Minhas,

     

    Modify your html like below

    <tbody>

    <template for:each={Tasks} for:item="task">

    <tr key={task.Id}>

    <td>{task.Name}</td>

    <td>{task.Start_Date__c}</td>

    <td>{task.Due_Date_c}</td>

    <td>{task.Actual_completion_Date_c}</td>

    <td>{task.Status_c}</td>

    <td>{task.Owner.Name}</td>

    <td class="slds-size_1-of-10" data-label="">

    <a onclick={openEditModal} data-id={task.Id}>

    <lightning-icon icon-name="utility:edit" alternative-text="edit" title="Edit" size="xx-small"></lightning-icon>

    </a>

    <a onclick={handleDelete}>

    <lightning-icon icon-name="utility:delete" alternative-text="delete" title="Delete" size="xx-small" class="slds-m-left_x-large"></lightning-icon>

    </a>

    </td>

    </tr>

    </template>

    </tbody>

    As you can see, we have added a data-id attribute to the anchor element that triggers the openEditModal() function. This attribute will store the record ID of the task that needs to be edited.

    you can modify the openEditModal() function to retrieve the record ID from the data-id attribute and pass it to the lightning-record-edit-form component:

    openEditModal(event) {

    var recordId = event.currentTarget.dataset.id;

    var editForm = this.template.querySelector('lightning-record-edit-form');

    editForm.recordId = recordId;

    editForm.submit();

    }

0/9000

Hi all.  We are in the process of migrating to Lighting and one of the things we're noticing is how a dashboard table component looks in Classic vs. how it looks in Lightning, specifically to the data.  What I mean is, we have a dashboard with a table component and in Classic it shows certain data that is different than what we're seeing in Lightning.  The other thing I'm seeing is that in Lightning I can't even edit this component.  Attached are screen shots of the same component, in the same environment, but one in Classic and the other in Lightning.  The Members and Groups columns are report formulas that were built a while ago in Classic.  I'm also attaching the actual report formula in Classic to show what we've got going on.  What am I missing here?  Do I need to adjust the decimal places in Classic?  If so, why is it different between Lightning and Classic?  If anyone can shed any light on this or provide some help, I would greatly appreciate it.  Thanks!

13 件のコメント
  1. 2020年1月22日 17:40

    Unfortunately you're gonna have to create a Formula(Text) field on the object like this

    Datatype = Formula

    Result = Text

    Formula =

    TEXT(YEAR( Effective_Date__c ))

    or

    TEXT(YEAR( Effective_Date__c ))

    +"-"+

    LPAD(TEXT(MONTH( Effective_Date__c )),2,"0")

0/9000
I have been working on some new dashboards today and was shocked to find that the table component can not display the average of the column in the total/summary row, only the sum of the column. Thanks to @Steve Molis answering a user's question in the community, I have a workaround (https://success.salesforce.com/answers?id=90630000000i6DyAAI). Please go here: https://success.salesforce.com/ideaView?id=08730000000gR3VAAU&sort=2 and vote to have this idea become a feature. Thank you! @Women in Tech @WIT Group, Atlanta, US @Admin Group, Atlanta, US @Admin Group, Columbia, MD, US @Admin Tricks

Idea Exchange: Table Component on the Dashboard to include an option to Show Average

14 件のコメント
0/9000