Login Register

DatePicker: lots of new stuff happening here!

With the upcoming release of Dojo 0.4.0 approaching ever so quickly, an updated version of DatePicker has been released. Over the past few months many people have been crying out for new features for dojo.widget.DatePicker. Over the past 2 months, these cries have been met with more and more improvemnets. The most recent one being i18n support for the text displayed in DatePicker. This was a great achievement and made the DatePicker that much more fiendly for people around the world to use. With that being said, lets get on with the new and improved DatePicker. The advantages of the new DatePicker are quite numerous. You, the community. have asked for a lot of nice features, and here is our response. You asked for a "startOnMonday", we give you the ability to start the week with any day. You can either let Dojo decide this for you, or specify weekStartsOn=0-6 (0 being Sunday ... 6 being Saturday). Then you asked for a way to have 2 DatePickers work together... "I don't want the user to be able to pick any dates in DP2 unless they are greater than DP1's value." Done, I give you startDate="YYYY-mm-dd" and endDate="YYYY-mm-dd". As you may have guessed, this limits the user to only picking dates that are greater than startDate or less than endDate. This feature is inclusive, if you pick the 1st of January 2005, that date will be available for selection, you are providing a range of available dates for the user to choose from. You asked "why can't I just show 28 days in February... why the extra 14 days...", we give you adjustWeeks and displayWeeks. If you set adjustWeeks=true, your calendar will display only enough weeks to display the current month, and if you set displayWeeks=X, DatePicker will only show X weeks. This update also includes staticDisplay, which prevents a user from changing the displayed month. The other big change with DatePicker is that storedDate is going away. It has been deprecated and replaced by "date" which is a much more intuitive name. If you pass date="YYYY-mm-dd" (RFC 3339 Format) via markup, your DatePicker will default to that date. The entire dojo.widget.DatePicker.util.* has been removed and replaced with features from dojo.date.*. With all these changes, now DropDownDatePicker will automatically start at the date entered in the inputNode if you click the dropdown button. Well with all that being said, here are some screen shots to show off a few of the features in action. This shot shows how the month would look if Friday was the first day of the week.
DatePicker weekStartsOn= Here is a 3 week display, created by setting displayWeeks="3" in the markup.
Karl said, A shot of a calendar with a very narroow range of available dates.
Pick any date...out of these 15... And one last one, showing how September looks on a paper calendar (no excess weeks)
Only show me what I need to see, nothing more! As always, if there are any suggestions, let us hear em! And if you happen to find a bug, let me know so we can get it fixed right away! I would love to hear what the users think of this change. Per user feedback: I want to know what you, the users think... should DatePicker handled the "weekStartsOn" feature as 0=Sunday and 6=Saturday or as 0=Monday and 6 = Sunday? If you have an opinion either way, or could care less, your feedback is beneficial here! Thanks again for all the great feedback on the new DatePicker! Update: Just so you dont have to read all the comments to see the entire update to DatePicker. Users can now assign a filter function to isDisabledDate="myFunction" and as long as you define myFunction to return TRUE for the dates you want disabled, it will work. I have also updated the UI, now you can selected any date on the display without the fear of it switching months on you, and along those same lines, the controls now hide/show if they are needed... Now DatePicker and DropdownDatePicker will not initialize with a "selectedDate" hlighted unless you explicitely declare one via date="....". That covers this update, There will only be bugfixes now on DatePicker until after 0.4 gets released.

Simply Awesome... Mike

Simply Awesome... Mike

Karl, I've been using the

Karl, I've been using the "Coolest DHTML Calendar" widget for several years now (http://www.dynarch.com/projects/calendar/) and it has served me quite well. I've been watching your progress on the Dojo datepicker and I think with these enhancements, it's time to switch. Well done!

Why do the month change

Why do the month change icons point up and down? That's counterintuitive. Is there a way to change the icons to be left and right facing?

Someone recently asked why

Someone recently asked why the arrows point up/down instead of left to right, and the reason that we designed them that way originally was because the week by week scrolling moves up and down, so it is more consistent with the UI...

What I'm missing is the

What I'm missing is the possibilty to have an additional column with a calendar week like in the calendar control of Outlook. But for now, great job!

I'm still working on it ;)

I'm still working on it ;) The latest suggestions have been: disableWeekends which prompted me to expand that idea to disabledItems which will consist of; { 'weekdays': true, 'weekends': true, 'days': {'0': true, '6': true}, {dates: {'2006-07-12': true, '2006-12-25': true}} Oh and also 'hiding' or 'graying out' the controls that are disabled is on my plate too... I'd rather get the bugs squashed first :). Once the i18n stuff for inputed dates is added in the formats will be more flexible than RFC3339 of course, but for now... thats what I'm looking at... ohh and with this I could easily expand to adding a 'holidays' CSS field as well to mark holidays... I also have been asked to turn out a double DP in 1 dropdown version to mimic the 2UP calendar from YUI... as well as a DP+TimePicker combo... sooo expect lots of new and exciting things :) (the TimePicker will hopefully make it into 0.4 but DP has been taking up a considerably large amount of my time (what my work and such doesnt already claim)). Well, glad my efforts have been such a great hit. It's great to know that it was an effort well spent. Keep the feedback coming!

Is there a way to only allow

Is there a way to only allow certain dates to be selectable? I'd like to have something that will only let people pick a Tuesday-Thursday for their start date.

Great work so far. Disabling

Great work so far. Disabling dates on the fly would be a great feature if its not in the works already. Lets say I have 2 calendars side by side (start .. end ) if I select a date on the start one, I want to be able to disable all dates prior to the selected one (for start) for the end calendar. So the user can only select all the dates > first one. Keep up the great work.

Hi, can i know the location

Hi, can i know the location of the newly released date picker component with all the above mentioned features. BHASKAR

Bhaskar:

Bhaskar: http://archives.dojotoolkit.org/nightly/ Aleanna: with the current setup, that should be possible, you just have to connect to setDate of calendar1 and do a bit with its calendar1.getDate() to send the needed info to calendar2... I may get around to actually writing a test case for this tonight, but I want to finish making the "disabledItems" feature tonight. Steve: you will soon be able to disabled any date(s) and or day(s) of week, so yes... you will be able to do that ;)

Great Work. It's starting to

Great Work. It's starting to get really impressive! One small thing that caught my attention though, the weekStartsOn property. I can certainly understand why the range of acceptable values are 0-6, as it's how weekdays has traditionally been represented in programming (think tm_wday). However wouldn't 1-7 (where Monday is one and Sunday is 7), as specified by the ISO-8601 standard, make more sense? Specifically now that date property uses the standard format?

You pose a valid point,

You pose a valid point, however... we (and in this case I really mean me) try to work with what Javascript gives us and by default, thats how DateObjects handle the weekdays... Sure, I mangle the weekdays for that feature anyways... but thats only if the week starts on something other than a Sunday... Let me update the blog entry and I'll include that question at the bottom, I'm certainly more than willing to accept that as the 'right way' to handle it if thats how the users get the impression it would be best. After all, you (and in this case I mean all of you) are the ones using DatePicker, not me ;) -Karl

Is there a way i can pick

Is there a way i can pick more than one date in the DatePicker? If not, is this feature in mind for the future? I thing is more useful to let the user pick a list of dates then a beginning and an ending date. If i didnt express myself correctly,im looking for something like this : http://www.calendarxp.net/tt_fin445.shtml Good day

In the new

In the new DropdownDatePicker, is it possible to use date="today" in the markup and display today's date in the input as default value? In 0.3.1, you can set default value using date="MM/dd/yyyy" to display the given date, but not today's date.

It currently isnt possible,

It currently isnt possible, if you do not specifiy a date in DDDP it defaults to todays date in the displayed Calendar, but not in the inputNode... I'll look into adding this as an option before 0.4 as I can see that being a valid thing... however, you have to remember that "today" for your user may not be "today" for your website...

Diego, Interesting idea,

Diego, Interesting idea, i would think that feature would condone the expanding of DatePicker to create a new widget... currently... there is no way to support that feature because the selected dates are stored in a Javascript Date Object which of course only allows 1 selected date to be stored... I do have some DatePicker stuff in mind that could use multiple selections... now would you need the entire year that way or would you still want the DatePicker layout for it? I dont see it being very User friendly w/o 1 month displayed...

"I want to know what you,

"I want to know what you, the users think… should DatePicker handled the “weekStartsOn� feature as 0=Sunday and 6=Saturday or as 0=Monday and 6 = Sunday?" Do it like cron: 0=Sunday, 6=Saturday, 7=Sunday OR just 0=Sun, 6=Sat NOT 0=Mon, 6=Sun

Well some bad news, the

Well some bad news, the current implementation of disabledItems will not be making it into the next release of Dojo, however a filter function method should be replacing it. This method won't be usable via markup declarations, but will provide more robust control over what dates are disabled, and which dates are enabled. example: myFilterFunction(date){ var disabled=false; if(date < this.startDate && date > this.endDate){ disabled=true; //date is not between start and endDate it should be disabled }else if(date.getDay()==0){ disabled=true; //no sundays allowed! } return disabled; } that would be an example of how... it will work with the proposed method. -Karl

ok, So I messed up my

ok, So I messed up my example a tiny bit.. the new implementation of disabledItems is as follows: isDisabledDate="dojo.date.isWeekend" where dojo.date.isWeekend accepts a dateObject, and returns false for dates you want enabled, and true for dates you want disabled... Should provide some added functionality to the way things were :) This will be in 0.4 also :D

Hi. The date picker looks

Hi. The date picker looks good---good work. I want to use it as follows. I want to use the calendar as a way to display links. My app is a photo management site (my hobby, I guess). I want to highlight the dates with pictures. From scanning the nightlies .js file, I think I can hook up listeners to the various events to get the list of "these days have pictures" list from the server. Right now my hand-rolled solution just fades in a new calendar with active dates that are genuine anchor tags, but I imagine I can rig up something in javascript to handle the clicks and check if the clicked date is in the list fetched from the server. However I don't see an easy way to style a particular day of a month to show that it is "active" (something will happen if you click on that date). Perhaps if you stuck a callback in the _getDateClassName: function, so that I can run the date past my list to style it red or something? For another app, I'd use a similar callback hook to toggle dates to be styled 'on' and 'off' to grab data to display, say to show on a map where I was for the past 4 summers. Thanks

Hi James, with the

Hi James, with the current nightly implementation, you can provide a fuction that will disabled all the dates that "dont have pictures"... and then you can just override the CSS style for active dates if that suits you... I'm currently running the idea of adding a function similiar to that for disabled dates to the CSS assignments.... see my above comment on how to use isDisabledDate="" for what you need :) Hopefully that works... as always, appreciate the feedback :) and also, for your clickHandlers... connect to 'onSetDate' event in the DatePicker object and you will get an event everytime a user clicks a date, then you can use dp.getValue() (RFC3339 format) or getDate() (dateObject) to do what you need.... -Karl

Karl, thanks for the

Karl, thanks for the pointer. I missed the isDisabledDate hook. I'll try that out, and I'll also try different ways to set styles for disabled/enabled dates and post if anything looks particularly elegant. But I'm sure y'all will come up with something faster and better. James

Well you didnt miss the

Well you didnt miss the hook, it was added yesterday if I remember right ;) As it stands now, DatePicker is complete until post 0.4, unless a bug is found with it. After 0.4, it is possible that more changes will occur, but other stuff needs attention as well :) -Karl

Hi, (this isn't the right

Hi, (this isn't the right forum for this but I might not remember to find the bugtracker...) For post 0.4, one small change I'd request is that the DatePicker.firstDay field be set to 0 hours, 0 seconds, like startDate. This will make comparing dates slightly easier, as the milliseconds will match a date like September 22, 2006. Happy coding towards 0.4, James

I would love a date

I would love a date selection widget that allows me to specify frequency as well. I create a lot of web based reports with financial data, and have to include methods for selecting dates at various frequencies (daily, monthly, quarterly, annual, etc). My solution for daily dates is not nearly as elegant as the DatePicker you've created here, but different frequencies is a requirement for me. Is there any other interest in a widget supporting different frequencies?

Matt, Can you show me an

Matt, Can you show me an example of what you've done, it might be really simple to extend DatePicker as a subWidget to do that... And James, I'll add that in, it was a planned thing, just not a high priority for 0.4. This will set the time of all important date objects to 0000.

Just a follow up... James,

Just a follow up... James, all date objects are set to 0,0,0,0 now, however, just for future reference, this doesnt simplify date comparisons because some odd rational in Javascript says that: var a = new Date(); var b = new Date(a);var c = (a==b); will result in FALSE... this is overcome by having to use timestamps and doing var c = (Number(a)==Number(b)); which will result in TRUE. But, as I said, this was a needed change to allow for future uses of DatePicker, so it's done now... although I may find out later that it just complicates future uses... time will tell, and lessons will be learned :) Thanks for your continued feedback! -Karl

Karl, The

Karl, The http://archives.dojotoolkit.org/nightly/ web site cannot be found :( Where can i download a last betta version? thx

Woops, that is a typo on my

Woops, that is a typo on my part, the url should be: http://archive.dojotoolkit.org/nightly/ My apologies :)

I've just started to look at

I've just started to look at the DropDownDatePicker, so please pardon my ignorance here. Does the DropDownDatePicker support an event to catch when the user alters the date (regardless of whether that change is through the pop down DatePicker or directly to the text entry box)? If I'm not interested in updating my entire 0.3.1 dojo install, is there a way to pull just the specific DatePicker and DropDownDatePicker updates from the nightly builds? If so, what set of files should I grab? Thanks, Ed

Ed, The onSetDate event

Ed, The onSetDate event shoudl work just fine for what you are looking for. As for replacing the 0.3.1 DatePicker, you will have to replaceall *DatePicker* files, along with i18n files, src/date/* files... It's no small task...

re: up/dn vs left/right

re: up/dn vs left/right month selection Hi Dylan, thanks for the feedback, I believe consistency isn't a great argument. Have someone to a quick usability test on non-tech users. Up/Down for month selection is counterintuitive at best. Perhaps you guys can leave both the week and the month icons configurable for left/right vs. up/down.

Karl, Is it possible to add

Karl, Is it possible to add a new property that limit displayed interval of weeks in the current month? e.g. add new property startWeek = 2 that display the period of time from the second week till the (startWeek + displayWeeks) one thx

UI minor bug: The DatePicker

UI minor bug: The DatePicker header increases by 100% in Internet Explorer 6.0 for a following code: in Firefox 1.5.x it's all right thx

code: div

code: div dojoType="datepicker" widgetId="foo" lang="en-us" displayWeeks="1" staticDisplay="true"

Dan, I dont understand

Dan, I dont understand your feature request... can you better explain it or do a screenshot that you can use to explain it better? As for the bug, I'll test it when I go back to windows since I'm not running it at the moment... looks fine in FF for linux as well :)

This is an absolutely

This is an absolutely fantastic product! Is there a sample anywhere on the site showing how to properly connect two datepickers together (startDate in Cal_2 based on Date in Cal_1)?

DatePicker makes a

DatePicker makes a calendar: --------------------- | ^ ^ October + + --------------------- | S M T W T F S --------------------- | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 .... | 29 30 31 1 2 3 4 --------------------- I would like to add a new "startWeek" property that sets a first shown week and a last shown week = (startWeek + displayWeeks) e.g. if (startWeek = 2) then DatePicker makes a calendar: --------------------- | ^ ^ October + + --------------------- | S M T W T F S --------------------- | 8 9 10 11 12 13 14 .... | 29 30 31 1 2 3 4 ---------------------

Ok... That definately wont

Ok... That definately wont be in 0.4 (feature freeze) but I'm not sure this is something that would really make a great feature (usefulness/lines of code) you can already kind of do this yourself... you would just have to (which maybe I need to make these functions on "private" because i can see them getting used more and more later on down the road) call dp._preInitUI(dateObjectSetToAnyDayInWeekX,true,true); and you got your display...

When will the 0.4 version

When will the 0.4 version released?

hi people, sorry - just

hi people, sorry - just more undocumented features. before developing more and more freatures please document all the otheres. new people just cannot use it wihtout documentation alex

I'm sorry, what feature is

I'm sorry, what feature is undocumented? please elaborate.

Pretty, but its not so good

Pretty, but its not so good when you want to quickly select a date several "years" back. Can you make this quicker? Perhaps have the year use the mouse wheel or start autoscrolling when you hover a certain section.

Define "several" since...

Define "several" since... 2-3 clicks isnt a big deal I imagine you mean more than 5 years... As it stands, keyboard/mouse integration I'm planning on discussing keyboard/mouse integration for an 0.5 release.

Karl, the flexibility of

Karl, the flexibility of DatePicker is awesome so thanks for that! I did wonder if it would be possible to have a date in a format like "MMddyyyy" rather then "MM/dd/yyyy"? This currently seems to fail but it seems doable by simply changing the dojo.date.format.formatPattern() method to use a pattern like "/([a-zA-Z])(?:\1?)+/g" rather than the current one of "/[a-zA-Z]+/g". It just adds a bit more flexibility to an already great widget. Of course, im no regexp guru so there may be a more efficient way to represent this same expression. Thanks a lot!

Do you mean for

Do you mean for DropdownDatePicker by chance? it does have a way of formatting the input value.... look at http://archive.dojotoolkit.org/nightly/tests/widget/test_DropdownDatePic... for examples :)

Yeah! I was referring to the

Yeah! I was referring to the DropdownDatePicker. I saw you can set display and save formats for the datePicker. The problem i was referring to is, the format for the datePicker seems to currently require some sort of delimiter between fields. (ie. "MM/dd/yyyy" works but "MMddyyyy" will not). It seems to be a deficiency in dojo.date.format, not the datePicker but i wasnt sure where else to ask about it.

Yes, this looks like a bug.

Yes, this looks like a bug. Greg, I've taken the liberty of filing a ticket for this (#1708) Feel free to use trac for this sort of thing and file patches if you've signed a CLA or if it's a trivial fix. Log in as guest/guest.

[...] dojo.widget: new

[...] dojo.widget: new widgets like Clock, FilteringTable, ProgressBar, plus enhancements to Editor2 and the AccordionContainer. Also localization of some widgets, such as DatePicker. [...]

A way to set what month is

A way to set what month is shown? I currently use date pickers for a time tracking program. We are always one month behind as it is for showing what we did the last month. None of the current date pickers easily allow that.