I used this calendar Date range picker in my web page, And want to show 24 months instead of 2 month.
I use this function numberOfMonts: '24'
but it can’t work for me. please see codepen
Thanks in advance 🙂
I used this calendar Date range picker in my web page, And want to show 24 months instead of 2 month.
I use this function numberOfMonts: '24'
but it can’t work for me. please see codepen
Thanks in advance 🙂
2
Answers
The option
numberOfMonts
is not there in https://www.daterangepicker.com/Instead daterange picker you can use two date picker controls.
something like this
fiddle: https://codepen.io/ravidevgam/pen/PoYdYeE
If I understood correctly you want to see 24 mini-calendars when you open the picker instead of 2. I think the only way at the moment is to change the library code.
If you open
datarangepicker.js
from the source code you have currently at row 101 the template definition:and can change it accordingly to have more of that
drp-calendar
divs (so 48 in that specific case).Then you have to build the calendars, there are the calls at rows 609-610 to
renderCalendar
that go to 619renderCalendar: function(side) { ...
and follow the changes, instead of usingthis.leftCalendar
andthis.rightCalendar
you could use an array of calendars.I think it should be doable pretty easily, maybe I would do it parametric with your
numberOfMonths
.The downside is that you will have to do that all over again every time you update the library. If you plan to update frequently I don’t think it isn’t even worth the effort to do it on the library and you should do directly a complete custom code. From a brief view to that file it seems there isn’t any easy approach to make an injection in the code or extending the methods/classes, there is too much to rewrite to make the calendars general enough.