Editor dateFormat of field

Editor dateFormat of field

digital-developer@fbu.comdigital-developer@fbu.com Posts: 2Questions: 1Answers: 0
edited May 2015 in Editor

I am using Editor 1.4.2.

I have implemented the Jquery UI Datepicker as mentioned on this page..
https://editor.datatables.net/examples/simple/dates.html

The format I want the datepicker to display is in the format "MM/dd/yyyy", and this is the format that shows after i pick a date from the Jquery date picker.

But when the form initially loads data (after clicking the edit button in the DataTable view), the date field never gets formatted originally to the format I specify, even though I am using the dateFormat option mentioned on that page.

Instead the field initially shows as
Wed May 27 2015 00:00:00 GMT+1200 (NZST)

My field definition looks like this...

{ label: "Expiry date:", name: "expiryDate", type: "date", dateFormat: 'MM/dd/yyyy'}

I have also tried using opts on this same field, but it doesn't work either.
"opts": {format: 'mm/dd/yyyy'}

How do I make sure my fields always display in the format I want in the Editor when the data first loads?

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    What format is the date field that is being loaded from the server and then also the format of the same field as shown in the DataTable? Are you using get and set formatters to transform from ISO8601 to the format you want in the server-side script?

    If you click in the "Server script" tab just below the table in the example you linked to, you will be able to see get and set formatters being used to change the date's format in the server-side script.

    Allan

  • digital-developer@fbu.comdigital-developer@fbu.com Posts: 2Questions: 1Answers: 0

    I am pulling the data from Parse.com, their dates are stored in ISO8601 format.

    I can't use server-side script as I am pulling the data directly from Parse.com, not my own server.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    Looking at the jQuery UI documentation it says of the setDate method:

    Sets the date for the datepicker. The new date may be a Date object or a string in the current date format

    So either the date much be in the format required, or as a Date object (the former is probably easier). I think there are basically two options:

    1. Use ajax.dataSrc to transform the data received from Parse into the date format you want
    2. Modify the date field type to add a transform from ISO8601 to the format required if ISO8601 is detected.

    It is somewhat frustrating this, I prefer the HTML5 date input type which uses ISO8601 as the wire format - but only Chrome desktop supports it at the moment.

    Allan

  • cliftonitecliftonite Posts: 8Questions: 0Answers: 0

    Is there any chance you could share how you wired up Parse.com data with Datatables?

    Was this a server-side processing implementation that makes calls to a Cloud Code function?

    How did you connect Datatables' pagination with the .skip() method to paginate Parse's data?

    I have so many questions. :)

This discussion has been closed.