DateTime display() as an option
DateTime display() as an option
Loren Maxwell
Posts: 469Questions: 114Answers: 10
For the DateTime plugin, display() is available through the api, but an option would be helpful as well.
{
label: 'Some date field',
name: 'some_date',
type: 'datetime',
opts: {
display: {
year: 1982,
month: 10
}
}
},
or maybe...
{
label: 'Some date field',
name: 'some_date',
type: 'datetime',
opts: {
display: [1982, 10]
}
},
The display option would probably only take affect if there is no current value or default value set.
This question has an accepted answers - jump to answer
Answers
Good idea! Added to the list
.
Allan
@allan -- just curious as to if this might be in the next version (1.6.2 or 1.7) of
datetime.I have several pages that represent years and Editors for the tables on those pages.
I don't want to set a default value because some of the dates will be unknown, but I'd like the calendar to be ready with the year set based on the page.
Otherwise changing the year on the calendar from 2025 to 1982 or whatever adds a couple of clicks and a scroll through the years for each entry.
I've tried to approach it this way:
However the calendar reverts back to the current date (and the2025 year) on
editor.val('game_date', '').Should I approach it differently? Or will you have the update done soon anyway?
I hope so, but can't say for certain while it will be done. I'm currently focused on a major update in DataTables core.
I don't know that there is a better option that getting it implemented I'm afraid.
Allan
Ok, thanks -- and thanks for all the great support!
Its been a funny old day here, so rather than trying to do a long period of focused work, I've been doing little bits and thought I'd look at this.
I was midway through writing a reply saying it would be a bit tricky to do, when inspiration hit! I've just made this commit to add support for a
displayoption on initialisation. Now if the field doesn't have a value then the picker will show that month / year. If it does have a value, then it displays that month / year of course.This is the option I went for:
to match the
display()return. Both properties are required.Allan
YAY! Looking forward to the release!
Tiny improvements like this have HUGE impacts when doing hundreds or thousands of repetitive entries!