Topic: How to put date in Datepicker

master@mastersistemas.net pro asked 6 years ago


Good morning, how can I manually enter the date in DatePicker? It automatically picks up today's date, but there are cases where I need to put that date dynamically, how can I do that? I did not find anything in the documentation.  

Jakub Mandra staff answered 5 years ago


You can load initial date via `value` proeprty, but DatePicker does not provide the functionality to update date value from outside.

 

Best,

Jakub


Muralidevx free answered 5 years ago


Hi I am trying to load date dynamically from state but it is not reflecting 


Mikołaj Smoleński staff answered 6 years ago


Hi there, For this moment it's not possible to update datepicker state manually. We've added this issue to our list of bugs. Best Regards

master@mastersistemas.net pro commented 6 years ago

Good morning, has this issue been resolved in Update 4.7.1?

Mikołaj Smoleński staff commented 6 years ago

It should be updated with the next release. Best Regards


Hi, I need to set the date of the two datePicker to today, when the user clicks reset. I'm trying this.
this.state= {

dataLast: date, }
 
getLast = (Value) => {

this.setState({dataLast: Value});

}
clear = () => {

var day = Date;

this.setState({dataLast: day}); }
<MDBDatePicker value={this.state.dataLast} getValue={this.getLast} className="select mt-0"/>
<Button rounded size="sm" color="white" onClick={this.clear}>Limpar</Button>
However, this causes me to close a loop and my page hangs.

How can I set the date to the DatePicker when I click a button?

Mikołaj Smoleński staff answered 6 years ago


Hi there, You can push Your date using 'value' attribute. Here is the example code:
const d = new Date(2017, 2, 12);
<MDBDatePicker value={d} getValue={this.getPickerValue} />
Best Regards


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.7.0
  • Device: Desktop
  • Browser: All
  • OS: All
  • Provided sample code: No
  • Provided link: No