You need to sign in to do that
Don't have an account?
Raghu.2020
Null check in LWC HTML
Hi,
I'm getting 'null' displayed in my LWC component. I do not want 'null' to be displayed.
HTML:
I'm getting 'null' displayed in my LWC component. I do not want 'null' to be displayed.
HTML:
<div class="slds-card__body"> <table class="slds-table slds-table_cell-buffer slds-no-row-hover slds-table_bordered slds-table_fixed-layout" role="grid"> <thead> <tr class="slds-line-height_reset"> <th class="" scope="col"> <div class="slds-truncate" title="Date">Date</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="Field">Field</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="User">User</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="Original Value">Original Value</div> </th> <th class="" scope="col"> <div class="slds-truncate" title="New Value">New Value</div> </th> </tr> </thead> <tbody> <template for:each={trackingData} for:item="track"> <tr class="slds-hint-parent" key={track.Id}> <td role="gridcell"> <div class="slds-truncate"> <p> <lightning-formatted-date-time value={track.CreatedDate} year="numeric" month="numeric" day="numeric" hour="2-digit" minute="2-digit" hour12="false"></lightning-formatted-date-time> </p> </div> </td> <td role="gridcell"> <div class="slds-truncate"> {track.e_eat__Enhanced_Audit_Tracking_Field__r.e_eat__Field_API_Name__c} </div> </td> <td role="gridcell"> <div class="slds-truncate">{track.CreatedBy.Name}</div> </td> <td role="gridcell"> <div class="slds-truncate" > <lightning-helptext content={track.e_eat__Original_Value__c}></lightning-helptext> {track.e_eat__Original_Value__c} </div> </td> <td role="gridcell"> <div class="slds-truncate"> <lightning-helptext content={track.e_eat__New_Value__c}></lightning-helptext> {track.e_eat__New_Value__c} </div> </td> </tr> </template> </tbody> </table> </div>
I am using the below code and I was getting an empty value and not a "null value" while printing them in a table can you try checking the values that are present and also the values that are being returned, below is the link to the reference code:
>> https://www.salesforcecodecrack.com/2019/07/lightning-data-table-with-sorting.html
Looking forward for your response.
Regards,
Anutej