Page 1 of 1

How to set default value in Calendar

Posted: 17 Jun 2020, 15:54
by mpprime
Hi.
I'm trying to put the default day into a Calendar component.
at the moment I set it fixed in the state:

Code: Select all

    this.state = {
            start: '18/06/2020'
        };
        
        
        <Calendar id="data_inizio" showIcon={true} value={this.state.start} required
                                          onChange={(e) => this.setState({start: e.value, minDate: e.value})}
                                          dateFormat="dd/mm/yy" monthNavigator={true} yearNavigator={true}
                                          yearRange="2020:2030" touchUI={true}/>
but the Calendar is always empty.

Re: How to set default value in Calendar

Posted: 11 Oct 2020, 01:07
by mert.sincan
Hi,

Sorry for the delayed response! Could you please try to add it as a Date object to value property?

Best Regards,

Re: How to set default value in Calendar

Posted: 17 Feb 2021, 15:18
by snake pliskin
Hi mert.sincan!

Please, example

Re: How to set default value in Calendar

Posted: 18 Feb 2021, 10:48
by snake pliskin
hi!
i solved the problem.
just need to initialize useState with a Date object.
as you said. thanks for the tip.

Re: How to set default value in Calendar

Posted: 06 May 2021, 22:57
by mert.sincan
You're welcome!

Best Regards,