Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #102523
    Matias Galante
    Participant

    Hello,

    What is the simplest way to format a date column to show  ‘MM/DD/YYYY’?

    What I tried:
    columns: [
    ...
    { label: 'Start Date', dataField: 'startDate', formatSettings: { dateFormat: 'MM/DD/YYYY' }, width: 150 },
    { label: 'End Date', dataField: 'endDate', formatSettings: { dateFormat: 'MM/DD/YYYY' }, width: 100 },
    ...
    ];
    new Smart.DataAdapter({
    ...,
    dataFields: [
    ...
    { name: 'startDate', dataType: 'date' },
    { name: 'endDate', dataType: 'date' },
    ...
    ]
    });

    When I pass a date object, regardless of the format specified above, it still defaults to the long date format such as Mon Nov 01 2021 …
    I’m using Angular by the way.

    #102527
    Yavor Dashev
    Participant

    Hi Matias Galante,

    For this purpose you can use the formatFunction property of the column like in the following code snippet to achieve the functionality that you need:

            { label: 'Time of Purchase', dataField: 'timeOfPurchase', width: 500,
                formatFunction: function(settings) {
                    const formatedDate = new Smart.Utilities.DateTime(settings.value).toString('MM/dd/yyyy ');
                    settings.template= <code><div> ${formatedDate}</div></code>
                }
            },

    Let me know if that works for you!

    Please, do not hesitate to contact us if you have any additional questions.

    Best regards,
    Yavor Dashev
    Smart UI Team
    https://www.htmlelements.com/

    #102529
    Matias Galante
    Participant

    Thank you! That worked

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.