Topic: mdb-date-picker-2 disable dates not in the array
ozgehan premium asked 3 years ago
Hi,
In datetime picker we have the option to disable dates which exist in array but i need to do opposite of that (disable the dates not in the array). I can do this by calculating dates but do we have an option or way to do this.
Thank you,
ozgehan premium answered 3 years ago
I tried to set disabled dates by substracting it from a certain date range and setting it to disabled dates but it makes mdb-date-picker very slow. so calculating dates is not working efficiently
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Premium
- Premium support: Yes
- Technology: MDB Vue
- MDB Version: 6.7.2
- Device: computer
- Browser: chrome
- OS: windows
- Provided sample code: No
- Provided link: No
Mikołaj Smoleński staff commented 3 years ago
Limits option is an interesting feature and could be useful in your case. In limits you only set the available set of dates.
https://mdbootstrap.com/docs/vue/forms/date-picker/#date-limits https://vue.mdbootstrap.com/#/forms/pro/datepicker2
Best regards
ozgehan premium commented 3 years ago
I think limit is only used for disabling dates in date time picker. I have an array of available dates and trying to disable all of the other dates. I cant find any way to just set available dates to date picker in your links. My array is just like this ["2020-01-24","2020-02-02","2020-02-04"] and I just want these three dates to be available.
Thanks
Mikołaj Smoleński staff commented 3 years ago
It seems your only option is to prepare a reverse for your available dates.
Best regards
ozgehan premium commented 3 years ago
do you mean setting disabled dates rather than available dates by saying prepare a reverse?
Mikołaj Smoleński staff commented 3 years ago
Exactly. There are several ways of disabling dates in date picker, but we have not prepared the opposite features for enabling set of dates. Best regards
ozgehan premium commented 3 years ago
Actually in the other comment I mentioned I did the way you suggested but it is not effective(datetime picker freeze for 2-3 seconds depending on your array size when you change months). for making 3 dates available, you shouldn't make an array of apprx. 7.665 dates (btw. 2000-2021) and set it to mdb-date-picker.
Anyways thank you.
Mikołaj Smoleński staff commented 3 years ago
Thanks for your remarks. We'll consider making an option for enabling only available dates in the new DatePicker component. Best regards