quasar icon indicating copy to clipboard operation
quasar copied to clipboard

[QDatetime] Initial view when opening datepicker

Open Snippo opened this issue 9 years ago • 4 comments

Currently the default view when opening the datetime picker is 'day'. In some cases, it would be useful if the default view is set to 'year' (e.g. when selecting a birth date, to make sure the right year is selected). Even better would be if it would start with year, then continue with the selection of the month and finally the day of the month.

The 'year' view which you also get by clicking on the year: datetime

I am willing to implement this myself, but I am still figuring out how to 'compile' the changes into a running app.

Snippo avatar Jul 28 '17 11:07 Snippo

I would try copying the original component’s folder into my own src and modify that You then import Datetime from your own /src/Datetime. No guarantees, but that would be my first approach. I’m sure when @rstoenescu comes back, he’ll show you how to do a proper setup and PR and all. Or maybe @smolinari or @pdanpdan would know how to guide you.

spectrolite avatar Jul 28 '17 12:07 spectrolite

Thanks, I managed to get it to work. I am able to open the datepicker in the 'year' view. However, it does not scroll to the current year. I guess this is achieved by this function inside view (value) {} : this.$nextTick(() => { view.scrollTop = rows * height(view.children[0].children[0]) - height(view) / 2.5 }) But inserting this in data() gives ""TypeError: Cannot read property '0' of undefined"". So I am not sure where the "view" variable originates from.

Edit: If I set this.$refs.selector.scrollTop in mounted() it will not work, not sure why not.

Edit: I know why it is not working, but I am not sure how to get it to work. The scrollTop variable should be changed after the view is displayed. However, I can't figure out how to do this. I believe mounted() is called when the component is rendered, not after it is displayed.

Snippo avatar Jul 28 '17 13:07 Snippo

I pushed a commit to my fork: https://github.com/Snippo/quasar/commit/763be2f5a890fcc47b19821c100ad2dca6079814

This seems to work fine but maybe there is a better approach.

Snippo avatar Jul 30 '17 13:07 Snippo

Available in v0.15. Forgot to close this.

rstoenescu avatar Feb 24 '18 23:02 rstoenescu