Date(time) format problem

Date(time) format problem

StevenRaekelboomStevenRaekelboom Posts: 5Questions: 2Answers: 0

Hi all

I'm using datatables in conjunction with the editor library for inline editing.
In my date(time) fields I can't seem to define a format that will only be used for display and editing because I would like to send/receive only ISO formats to/from the server.
Can anyone tell me how to do this?

Thanks in advance!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    There are two options:

    1. Use the ISO format as the "wire" format (i.e. what is in the JSON) and a renderer to make it readable to the end user in the table.
    2. Have both the ISO and the formatted version in the JSON. DataTables would be told to show the formatted version, while Editor works off the ISO format.

    Regards,
    Allan

  • StevenRaekelboomStevenRaekelboom Posts: 5Questions: 2Answers: 0

    Hi Allan

    Thank you for your answer.
    In fact I was already using a renderer in the table:

     "columns": [
       {
        "data":"Date_created",
        "type":"date",
        "render":
            function(data, type, full) {
              return (data) ? moment(data).format('DD/MM/YYYY') : '';
            }
       }
      ],
    
    

    and it displays correctly. It is when I activate the inline edit that the display changes to the format that is defined in the editor so it shows f.i. 2016-09-06 and if I define a format for the editor, it will also use that value to send to the server.
    In the library I was using before I had the possibility to define a viewformat which fit my purpose. I was hoping to find something similar in editor.
    Sorry for being unclear before.

    Regards

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin
    Answer ✓

    I understand - thanks for the clarification. Unfortunately, at the moment Editor's datetime field does not support two different formats (wire and display). It uses the same format for setting and getting.

    That is something I would like to add in future, but it isn't available yet I'm sorry to say.

    Allan

This discussion has been closed.