0

Only first column is displaying, I can see all the other columns in an array in the console.log
Apex returns contact data in a wrapper class.

html

    <template>

 <lightning-card>
 <lightning-datatable style="height:120% !important;display: block;"
                class="slds-button_icon-bare"
                key-field="id"
                data={resultReceived}                        
                hide-checkbox-column
                columns={columnsList}
                onrowaction={handleRowAction}>
            </lightning-datatable>   
        
    </lightning-card>
    </template>

Javascript code;

import { LightningElement, api } from 'lwc';
import getContactData from '@salesforce/apex/create_Testlog.getCntData';
const colums =[   
    {label:'Name',fieldName:'Name', type:'text'},  
    {label:'Phone',fieldName:'Phone', type:'number'},  
    {label:'Email',fieldName:'Email', type:'text'},
    {label:'Fax',fieldName:'Fax', type:'number'}
   }]; 
export default class MyRecordEditForm extends LightningElement {
    @api recordId;
    @api resultReceived;
    retrievedRecordId; 
    cardTitle='Call Log';
    columnsList = colums;

    connectedCallback(){
        if (!this.retrievedRecordId && this.recordId) {            
            this.retrievedRecordId = true; // Escape case from recursion            
            this.getPrePopulateData();                             
        }        
    }

    getPrePopulateData(){
        getContactData({recordId: this.recordId})
        .then(result => {
            let tempAllRecords = Object.assign([], result);
            window.console.log('data--1 ', tempAllRecords); 
           
            for (let j = 0; j < tempAllRecords.length; j++) {
                      
                
                let cntRec = Object.assign({}, tempAllRecords[j]);
                
                tempAllRecords[j] = cntRec;
                window.console.log('data --092 ', cntRec);
               
            }
            
            this.resultReceived = JSON.parse(JSON.stringify(tempAllRecords));
            window.console.log('data--3 ', this.resultReceived);
                       
           
        })
        .catch(error => {
            this.error = error;
            window.console.log(' error ', error);
            this.result = undefined;
        });

    }
4
  • 1
    Check errors on the console. You haven't closed to colums array, there is } instead of ]. Jan 8 at 4:44
  • 1
    Rahul that bracket missed while copy pasting.
    – Suresh
    Jan 8 at 18:06
  • Ahh! Do you see any errors on the console? Jan 8 at 18:47
  • No Errors, I see all the data as expected in the console.
    – Suresh
    Jan 10 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.