Innologica / vue2-daterange-picker

Vue2 date range picker
https://innologica.github.io/vue2-daterange-picker/
MIT License
329 stars 208 forks source link

Programmatically chaining the month as we open the calendar. #280

Open krishdev opened 2 years ago

krishdev commented 2 years ago

Is there a way to open up the calendar without default dates and go to a desired month?

For instance: Current month is November 2021, If I had to open up the calendar with the month and year set to January 2022 and let the user directly pick a date from Jan instead of letting them do it.

Any help or future enhancements is greatly appreciated.

nkostadinov commented 2 years ago

You can actually do this in the current version. You need to set a ref to the datepicker component and then after open (@toggle event) you can write something like:

this.$refs.picker.changeLeftMonth({ year: 2021, month: 1 })

I havent tested it, but you can try and say if it works.

nguyenduc308 commented 2 years ago

@nkostadinov I have tried it, not worked for me

nguyenduc308 commented 2 years ago

Now it's working, i wrap it in settimeout for waiting the 'watch.open' is triggered

timmaybrown commented 1 year ago

i had to wrap this in a

this.$nextTick(() => { //...changeLeftMonth() stuff here }