creativetimofficial / ct-material-dashboard-pro

Material Dashboard Pro - Premium Bootstrap 5 Admin
https://demos.creative-tim.com/material-dashboard-pro/pages/dashboards/analytics
116 stars 28 forks source link

Datepicker - viewmode not remembered #271

Open andrea-iezzi opened 4 years ago

andrea-iezzi commented 4 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Expected Behavior

viewMode: 'months'

Current Behavior

The datepicker show the view mode (months) only the first time. After you select the date, it forgets the view mode

groovemen commented 4 years ago

Hello @andrea-iezzi,

Thank you for using our products and sorry for this late response. This is the default behavior of this plugin, you have to refresh the page to show again the view-mode that you set. Here you can find an example of view mode: https://eonasdan.github.io/bootstrap-datetimepicker/#view-mode Hope that information helps you. Please let us know if we can help you with anything else.

All the best, Stefan

andrea-iezzi commented 4 years ago

Thanks for your reply. The example works different. If i chose a date and then (without reloading the page) I choose another, it keeps the setting. Unfortunately, I don't have this behavior in my app with your plugin

groovemen commented 4 years ago

Is there any possibility to share with us your project? Also, until then, please search into Bootstrap Datepicker repo for this issue: https://github.com/Eonasdan/bootstrap-datetimepicker/issues Cheers, Stefan

andrea-iezzi commented 4 years ago

It's impossible for me to share the project. The problem is easy to reproduce.

If you try to change the default function initFormExtendedDatetimepickers in the material-dashboard.js file, you will reproduce my problem.

In this part of code code $('.datepicker').datetimepicker({ format: 'MM/DD/YYYY', icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-chevron-up", down: "fa fa-chevron-down", previous: 'fa fa-chevron-left', next: 'fa fa-chevron-right', today: 'fa fa-screenshot', clear: 'fa fa-trash', close: 'fa fa-remove' } });

I changed the format (from MM/DD/YYYY to MM/YYYY) and i added this line viewMode: 'months' after the format.

In this way, you can reproduce my issue in the Extended Forms page

groovemen commented 4 years ago

We just found this Pull Request on Datepicker Github Repo that fixed this bug: https://github.com/Eonasdan/bootstrap-datetimepicker/pull/1809 Please let us know if we can help you with anything else.

Best, Stefan

andrea-iezzi commented 4 years ago

I saw that pull request and the solution is in the latest version of Eonasdan plugin. Are in your template the latest version of plugin? If yes, for me of course, it doesn't work.

Did you follow my advice (to change the default function)? It works?

groovemen commented 4 years ago

We followed your example and noticed that it doesn't work. We are using the Datepicker version 4.17.47. Until we find a solution to this issue you can press the Month and year on the top of dropdown and will switch to months view.

Screenshot 2020-03-26 at 10 02 39 Screenshot 2020-03-26 at 10 02 47

Sorry for this inconvenience. All the best, Stefan