I am trying to open the date picker dialog from a Raised button, which is inside a toolbar element, with no joy.
After going through the documentation I found no solution. I tried putting the Date picker inside the Flat Button like so:
<RaisedButton label="Start Date" onTouchTap={this.handleRaisedButtonTap} primary={true}>
<DatePicker autoOk={true} formatDate={this.datePickerFormat} hintText='Start Date' label='Start Date' value={this.state.filter.startDate.display} />
</RaisedButton>
I would like to open the date picker dialog when the button is clicked.
Any help would be greatly appreciated
For using the Datepicker component, we also need to install the Material UI Pickers package Install the date-io package to perform various basic date operations Note: For material-ui-pickers v3 use v1.x version of @date-io adapters. There are a number of UI components provided by Material UI package modules.
You need to install 3 different types of package to make the pickers work: The component ( @mui/x-date-pickers or @mui/x-date-pickers-pro) manages the rendering. The date-library ( moment, dayjs, ...) manages the date manipulation. The adapter ( @date-io) exposes your favorite date-library under a unified api used by component.
As part of Material-UI v5, the pickers are moving into @material-ui/lab ( next.material-ui.com/components/date-picker) and will likely experience some changes to the API while in the lab. @ Ryan will refrain from using it then. I need the date range picker, but it appears that material-ui is only making that available through its premium package.
The variant property is used to change the style of the Datepicker. There are three types of variants available "dialog" (default), "inline" & "static" The static date picker is placed as an element and copies space. The Dialog variant is displayed in the center of the page, useful for mobile or small interfaces.
you have to open it from the refs of the DatePicker component
openDatePicker(){
this.refs.dp.openDialog()
}
render(){
return (
<div>
<RaisedButton onTouchTap={this.openDatePicker} label='open date picker' />
<DatePicker ref='dp' />
</div>
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With