diff --git a/force-app/main/default/lwc/stickySelectronDataCell/stickySelectronDataCell.js b/force-app/main/default/lwc/stickySelectronDataCell/stickySelectronDataCell.js index 9c09b54..fc97ce5 100644 --- a/force-app/main/default/lwc/stickySelectronDataCell/stickySelectronDataCell.js +++ b/force-app/main/default/lwc/stickySelectronDataCell/stickySelectronDataCell.js @@ -25,10 +25,20 @@ function formatDateTimeLocale(dateStr, hasDate, hasTime) { timeZone: TIMEZONE }; if (hasDate) { - options.dateStyle = 'medium'; + // Note that setting to short will have a 2-digit year, but we want 4 digit + //options.dateStyle = 'short'; + + options.year = 'numeric'; + options.month = '2-digit'; + options.day = '2-digit'; } + // If we leave default formatting (not setting date and time options) then time is not shown if (hasTime) { - options.timeStyle = 'short'; + // timeStyle short is the format we want, but since we need a 4 digit year, we need to set the time components manually + //options.timeStyle = 'short'; + + options.hour = '2-digit'; + options.minute = '2-digit'; } return new Intl.DateTimeFormat(LOCALE, options).format(new Date(dateStr)); } @@ -70,7 +80,13 @@ export default class StickySelectronDataCell extends LightningElement { get fieldValForObject() { const inputVal = this.object?.[this.fieldName]; - if (inputVal) { + // We may get a zero value from Apex that should still be rendered with our JS formatting + if ( + inputVal || + this.sfType === 'CURRENCY' || + this.sfType === 'PERCENT' || + this.sfType === 'DOUBLE' + ) { if (this.sfType === 'DATETIME') { const hasDate = true; const hasTime = true; diff --git a/force-app/main/default/lwc/stickySelectronMain/stickySelectronMain.html b/force-app/main/default/lwc/stickySelectronMain/stickySelectronMain.html index a4a8ba0..f0f4683 100644 --- a/force-app/main/default/lwc/stickySelectronMain/stickySelectronMain.html +++ b/force-app/main/default/lwc/stickySelectronMain/stickySelectronMain.html @@ -58,7 +58,7 @@ class="slds-float_left slds-var-m-top_xx-small slds-var-p-around_x-small slds-scrollable_y grid-main" > -