user1816491
user1816491

Reputation:

React and material-ui/DatePicker: how can I change to year view programmatically?

I've a DatePicker

<DatePicker/>

in my component and it is rendered correctly, everything works properly but I need in my special use case only year view.

There is a function in a child component of DatePicker (Calendar):

yearSelector()

and it will called if I click on the year:

enter image description here

My question is: How can I call it programmatically, as far as DatePicker rendered in my component, so that I see only the year view like below:

enter image description here

Upvotes: 3

Views: 6101

Answers (1)

TomLgls
TomLgls

Reputation: 609

So if I understand, you want to force your calendar to first ask the user to select a year?

You can try this :

openToYearSelection={true}

You can see this code on datepicker documentation and the pullrequests

Upvotes: 1

Related Questions