My Coloum header are still getting displayed even if there is no data in datatable. I want to hide it in case it doesnt contain any data. I have contained my Datatable in template. but still the column header are getting displayed! Any solutions?
<template>
<p id="custom" class="slds-box slds-text-heading_small" style="background-color:WhiteSmoke;">
<lightning-icon icon-name="custom:custom11"></lightning-icon> <b style="font-size:14px">Selected EGs ({count})</b>
</p>
<template if:true={showPPGRecords}>
<div>
<lightning-datatable key-field="Id"
data={priclst}
columns={columns}
hide-checkbox-column="true"
show-row-number-column="false"
>
</lightning-datatable>
</div>
</template>
</template>
import { LightningElement,api,wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import { getRecord } from 'lightning/uiRecordApi';
import getSelectedEGs from '@salesforce/apex/PricingRequestGenericController.getPPGEGRelatedList';
const FIELDS = ['Account.Relationship_Status__c'];
const columns = [
{ label: 'Title', fieldName: 'Title__c' },
{ label: 'Entitlement Id', fieldName: 'EG_Number__c' },
{ label: 'Number', fieldName: 'Bse_c' },
{ label: 'Related Party', fieldName: 'MA3__c' } ,
{ label: 'Center', fieldName: 'Center__c' },
];
export default class RelatedEGForProductPricingGroup extends NavigationMixin(LightningElement) {
@api recordId;
@api objectApiName;
isNewVisible = true;
Account;
currenObjectName;
error;
columns = columns;
priclst=[];
callChildCmp;
currenRecordId;
showPPGRecords=false;
hideHeader = false;
count='';
//End Code
connectedCallback() {
this.currenRecordId = this.recordId;
this.currenObjectName = this.objectApiName;
getSelectedEGs( { currentRecordId:this.recordId} )
.then(result => {
if(result)
{
this.showPPGRecords = true;
this.priclst=result;
this.count = result.length;
}
else{
this.count = 0;
}
})
.catch(error => {
this.error = error;
});
}
handleView()
{
var compDetails = {
componentDef: "c:relatedlstNavPricingApproval",
attributes: {
//passing reordId to the next lwc component
getIdFromParent: this.recordId,
getObjectApi:this.currenObjectName
}
};
var encodedCompDetails = btoa(JSON.stringify(compDetails));
this[NavigationMixin.Navigate]({
type: 'standard__webPage',
attributes: {
url: '/one/one.app#' + encodedCompDetails
}
});
}
handleNew()
{
this.callPricingApproval=true;
}
handleNewPricingRequest(){
this.callPricingGenericCMP=true;
}
}