Question

Change display format for Section List Date Column

Hi everyone,

 

I am trying to change the display format of the date column (circled in red) to dd-MMM-yyyy (e.g 01-NOV-2023) in the section list without making any changes to the data object. Is there any way to do this? 

 

Thank you.

 

Like 0

Like

1 comments

To accomplish this you could try adding something like the following to the section schema:

// assuming your date col is UsrDate
 
prepareResponseCollectionItem: function(item) {
    this.callParent(arguments);
 
    var dateCol = item && item.columns && item.columns.UsrDate;
    if (dateCol) {
        dateCol.dataValueType = Terrasoft.DataValueType.TEXT;
 
        var newDateVal = item.values.UsrDate.toLocaleDateString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
        item.set("UsrDate", newDateVal);
    }
}

This converts the date column to a text column in the rendered list. Then you can set it as a string value however you want. The code above would render the date as something like "Nov, 8 2023". Note, I believe that sorting will not work the same since it's sorting by text values and not dates.

Ryan

Show all comments