Editor - Date formatting weirdness

Editor - Date formatting weirdness

dpanscikdpanscik Posts: 119Questions: 32Answers: 0

I am using date formatting ddd, DD MMM YYYY I love it. I feel its the most international / world friendly date format.

It looks like this in datatable

However when I click on inline editing it looks like this

And editor popup it looks like this

I think? I am properly instructing editor what date format to use...

        editor = new $.fn.dataTable.Editor({
            ajax: '/api/APData',
            table: "#ApForm",
            "data": function (d) {
                return $.extend({}, d, {
                    "form_id": "APgrid",
                });

            },
   
            formOptions: {
                inline: {
                    submit: 'allIfChanged',
                },
            },
            fields: [
                {
                    label: "EmailReceivedDate",
                    name: "EmailReceivedDate",
                    type: "datetime",
                    format: "ddd, DD MMM YYYY"
                },
                {
                    label: "InvoiceDate",
                    name: "InvoiceDate",
                    type: "datetime",
                    format: "ddd, DD MMM YYYY",
                },


            ]

        });

Answers

  • allanallan Posts: 61,439Questions: 1Answers: 10,052 Site admin

    Looks like you need to use wireFormat and displayFormat since your wire data is ISO8601. See this example.

    Allan

  • dpanscikdpanscik Posts: 119Questions: 32Answers: 0

    wireFormat: "YYYY-MM-DD" did not work for me. I think there is more to it... a missing javascript include perhaps.

    what did work is changing in Model the date field from date to string

    Odd... I would expect the opposite. I would expect a date field labeled as a string to cause formatting weirdness. However in my situation a date field labeled as a date field causes weirdness.

  • allanallan Posts: 61,439Questions: 1Answers: 10,052 Site admin

    Looks like your wire format is actually:

    YYYY-MM-DDTHH:mm:ss
    

    Allan

Sign In or Register to comment.