0

I have the following data as an array:

this.finalSObjectDataListChild = sObjectRelatedFieldListValues;
         console.log(this.finalSObjectDataListChild);

enter image description here

From an icon-button on the row I trigger an onrowaction: handleRowAction(event) The array gets updated with the selected data, but my array stays empty. What am I missing? My debug shows the following:

    handleRowAction(event) {
        const dataRow = event.detail.row;
        this.finalSObjectDataListChild = dataRow;
        window.console.log('this.finalSObjectDataListChild: ' + this.finalSObjectDataListChild);
        window.console.log('this.finalSObjectDataListChild: ' + this.finalSObjectDataListChild.Name);
        this.modalContainer=true;
   }

enter image description here

I only see the column labels in my modal see:

enter image description here

Why dont I get the values in the columns? Thanks in advance.

UPDATE: this.finalSObjectDataListChild = [dataRow];

This gives me te following: enter image description here

I would like to achieve the following: [{Name: 'Basic, 12 months, 1 sector', My_Duration__c: '12 months', OwnerId: '0000p000009G8FxAAA', Id: '0000p000009G8FxAAA', Owner.Name: 'John Do', …}]

1 Answer 1

1

event.detail.row isn't an Array, it's a single object. You may have meant:

this.finalSObjectDataListChild = [dataRow];

Which would make it suitable for lightning-datatable.

5
  • Thanks for helping out. [dataRow only gives me the first value of the row. How do I pas the complete selected row as for example [{ "Name": "Basic, 12 months, 1 sector", "My_Duration__c": "12 months", "Owner.Name": "John Do", ...}]
    – Thomas
    Oct 18, 2021 at 13:13
  • @Thomas your field mapping may be incorrect. The route property is definitely the entire row data.
    – sfdcfox
    Oct 18, 2021 at 14:02
  • Is there a way to get the index of the array? I tried so many examples but no avail.
    – Thomas
    Oct 18, 2021 at 14:06
  • @Thomas const rowIndex = this.tableData.findIndex(row => row.Id === event.detail.row.Id) is one such example, given that this.tableData is the source data you're working from.
    – sfdcfox
    Oct 18, 2021 at 14:23
  • Any reasons why the rowIndex always retuns -1 if not row 0?
    – Thomas
    Oct 18, 2021 at 23:12

You must log in to answer this question.

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