Editor: render a datetime field for display

Editor: render a datetime field for display

rldean1rldean1 Posts: 141Questions: 66Answers: 1

Long story short, I have data coming back from the server with a full-on Datetime "YYYY-MM-DDTHH:mm:ss".

I followed some articles to get it displayed correctly in Datatables by adding these srcipts, and using the renderer:

<script src="../javascript/moment.min-2.22.2.js"></script>
<script src="../assets/DataTables-1.10.18/Plugins/dataRender/datetime.js"></script>

                columns: [
                    {
                        data: 'EffectDate',
                        title: 'Effective Date',
                        render: $.fn.dataTable.render.moment("YYYY-MM-DDTHH:mm:ss", "MM-DD-YYYY"),
                    },

OK, so here's the question:

How do I do this in DT Editor?

I tried to use the same renderer, but it had no effect. I will also want the Editor calendar to pop-up, just FYI.

                fields: [
                    {
                        label: "Effective Date:",
                        name: "EffectDate",
                        type: "datetime",
                        format: 'MM-DD-YYYY',
                        render: $.fn.dataTable.render.moment("YYYY-MM-DDTHH:mm:ss", "MM-DD-YYYY")
                    },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    Answer ✓

    Hi,

    Editor doesn't have a rendering function in the same way DataTables does I'm afraid. It assumes that you will want to edit in the format that the data is given to it as.

    So in this case there are two options:

    1. Change the format for how the data in sent to the client- instead of the ISO8601 format return it already formatted.
    2. When loading the data from the server, modify the format before DataTables gets ahold of it.

    Allan

This discussion has been closed.