Bootstrap-datepicker: Multiple months display

Created on 18 Nov 2014  路  32Comments  路  Source: uxsolutions/bootstrap-datepicker

Is there any way to display two or more months at the time? I would like to achieve the effect close to jQuery UI as you can see there http://jqueryui.com/resources/demos/datepicker/multiple-calendars.html

is-feature release-next

Most helpful comment

+1 this feature would make this datepicker even more awesome ;-)

All 32 comments

I really love this datepicker and also need that feature. If is possible add multiple months view, whit something like 'showCurrentAtPos' for the offset of current month (like 'show 3 month with current date at second month).
Thanks!

+1 this feature would make this datepicker even more awesome ;-)

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

Please use the recently introduced reactions to share your interest for this feature. I'm locking this issue to collaborators only for now, to avoid spamming all the participants with "+1" mails. Locking the issue disables reactions, I'm leaving this open for now.

For some use cases you could use multiple datepicker to achieve this. Here is a JSFiddle: https://jsfiddle.net/v6q2rxs0/

In short:

  • Create multiple datepicker and adjust the month which is initially displayed by defaultViewDate option.
  • Sync selected dates by a combination of changeDate event and setUTCDate method. Watch out that setUTCDate method triggers changeDate event. Could easily cause an infinitive loop.
  • Listen for changeMonth events and change displayed month on other calendars accordingly. You could do so by private method _setDate which allows to change viewDate.
  • Since setUTCDate changes viewDate you have to fix it afterwards.

Not tested much yet. Just a proof of concept.

Closed other tickets in favor of this one since @jelhan provided a nice snippet to link multiple datepicker.
BTW @jelhan if you want to get more involved since I see you gave some help around it, let us know.

@jelhan it seems like your code should work with unlimited number of calendars, although if I add third calendar it goes all crazy. Can't figure out why. Any help would be welcome.

@frankenstein-uk Could you please provide a JSFiddle demonstrating the issues you are facing? Did you noticed #1982? Setting updateViewDate to false makes implementing linked datepickers easier since setUTCDate method won't change view date anymore.

I've updated my JSFiddle to use updateViewDate. Also added support for multidate and showing 4 linked datepickers. Note that I'm using 1.7.0-RC1 since #1982 is not included in early releases. https://jsfiddle.net/v6q2rxs0/39/

The example fiddle is nice until you need to use multidate:true. Does anyone have an example of this?

Was this page helpful?
0 / 5 - 0 ratings