Problems with date fields
Problems with date fields
nerddad
Posts: 5Questions: 2Answers: 0
I'm new to the Editor but not to Datatables. I'm trying to get the date format to work in the Editor as well as the date picker to pop-up.
I have it working in Datatables via:
columnDefs: [ {
targets: 1,
render: function(data) {
return moment(data).format( date_format );
}
} ],
But I can't get it working in the Editor. I have it in there like:
{ label: 'Date', name: 'time_on',
type:'datetime',
format: date_format
},
But that doesn't seem to work:
And there is no datetime-picker that appears when I put that field into focus.
What am I doing wrong?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @nerddad ,
This thread should help, it's asking the same thing. If not, let us know, or modify one of those example in that page to demonstrate the issue.
Cheers,
Colin
It didn't really answer my question... I tried most of that and tried it all now and that didnt' work.
Here is a mock-up. there is no services, but it shows the problem when you try to edit a row, etc.
http://editor.squarepegsystems.com/
The datepicker does appear to be on the main screen... which is a problem.
Hi,
The key issue here is that Editor doesn't have a renderer like DataTables does - it will take the value for the field given by the server and use that. In this case that is a date stamp such as
20180723
.The
format
option for thedatetime
control lets you tell Editor what the format the data is in (not telling Editor how to convert it into something else) - in this caseYYYYMMDD
would be used, but that likely isn't what you want to show.The best way to do what you are looking for is to have the server return the date in the format that you want to display in the table and in the Editor form. Then in Editor use the
format
option for the field to tell it what that format is.At the moment it looks like you are just using a plain JSON file, are you planning on using a server-side process to write to that, or are you planning on using an SQL database (in which can you can use the get and set formatters that the pre-built libraries provide).
Thanks,
Allan
That isn't my app... just a mock-up of what I have. I'll work on the server-side to get the format right. This doesn't seem clear in the docs to me (or maybe unclear because the same property means the opposite of what it means in Datatables).
Thanks for the info. I'll give it a shot.
Yes that works! I'm going to transform the time on the server side to so there is no need for Datatables or Editor to do any work with it.