В моем веб-компоненте молнии метка столбца не отображается в Datatable. У меня есть 2 шаблона (acceptAttendance. html и appAttendance. html) в моем компоненте. Когда я нажимаю кнопку сохранения в appAttendance. html, шаблон в acceptAttendance. html попадает на экран. В этом шаблоне у меня есть дата для отображения списка контактов. Метка столбца не отображается в таблице данных, но я получаю данные в таблице.
Javascript file
import templateTwo from './acceptAttendance.html';
import templateOne from './appAttendance.html';
const fields= [NAME_FIELD,STAGE_FIELD,ATTENDANCE_FIELD];
const columns =
[{
lable:'First Name',
fieldName:'FirstName',
type:'text'
},
{
lable:'Last Name',
fieldName:'LastName',
type:'text'
},
{
lable:'Email',
fieldName:'Email',
type: 'email'
},
{
lable:'Account',
fieldName:'AccountId',
type : 'lookup'
}
];
export default class AppAttendance extends LightningElement
{
@api recordId;
@api objectApiName;
showTemplate=true;
attValue='';
sValue='';
lastName='';
email='';
address='';
@track value = 'None';
@track cData=[];
@track columns=[];
@track contactError = [];
@wire(getRecord, {recordId:'$recordId',fields})
stageDetails;
get decision()
{
this.lName=getFieldValue(this.stageDetails.data,LASTNAME_FIELD);
this.email=getFieldValue(this.stageDetails.data,EMAIL_FIELD);
this.address=getFieldValue(this.stageDetails.data,ADDRESS_FIELD);
let getStage ='';
getStage = getFieldValue(this.stageDetails.data,STAGE_FIELD)
if(getStage =='Accepted')
return true;
else
return false;
}
@wire(getContacts, {recordId:'$recordId'})
wiredContacts({ error, data }) {
if(data) {
this.cData = data;
this.columns=columns;
console.log('return data:'+this.cData);
this.contactError = undefined ;
}
else if (error) {
this.contactEror = error;
this.cData = undefined;
}
}
handleChange(event)
{
this.attValue='';
this.attValue =event.target.value;
}
switchTemplate()
{
if(this.attValue == 'Yes'){
this.showTemplate = true;
}else{
this.showTemplate = false;
}
this.showTemplate = !this.showTemplate;
console.log('returning record:'+wiredContacts.data);
}
render()
{
return this.showTemplate ? templateOne : templateTwo;
}
}
acceptAttendance. html
<template>
<lightning-card>
<h1 style="font-weight:bold; font-size:15px">Applicant Accepted Attendance</h1>
<div class="slds-m-bottom--medium"></div>
<template if:true={cData}>
<lightning-datatable
key-field="Id"
data={cData}
columns={columns}
onrowselection={getSelectedName}>
</lightning-datatable>
</template>
<template if:true={contactError}>
<p> No matching Contacts Found ! </p>
</template>
<div class="slds-m-bottom--large"></div>
</lightning-card>
Выход
[enter image description here][1]