material-ui-pickers icon indicating copy to clipboard operation
material-ui-pickers copied to clipboard

Open picker from a button

Open DarkKnight1992 opened this issue 8 years ago • 9 comments

Hi,

I am facing an issue to open the pickers by clicking on a external button, is that currently possible ?

DarkKnight1992 avatar Dec 13 '17 13:12 DarkKnight1992

Hi, yes it is possible

<DateTimePicker
   ref={node => { this.picker = node; }}
/>

<Button onClick={() => this.picker.togglePicker()}

dmtrKovalenko avatar Dec 13 '17 14:12 dmtrKovalenko

Thanks for quick response it works perfectly

DarkKnight1992 avatar Dec 13 '17 14:12 DarkKnight1992

there is one more thing, i am trying to do. Need to gray out all past dates (only gray out not disable they still needs to be selectable) is that possible ?

DarkKnight1992 avatar Dec 13 '17 14:12 DarkKnight1992

Yes, using renderDay prop - you can find description in readme, and example on demo, under CustomElemnts section

dmtrKovalenko avatar Dec 13 '17 14:12 dmtrKovalenko

oh thanks did knew this was the function i was looking for.

DarkKnight1992 avatar Dec 13 '17 14:12 DarkKnight1992

I just tried the 'togglePicker' method using a <DatePicker> and it doesn't appear to work. Maybe this is only on a <DateTimePicker>? Is there a way to open a <DatePicker> from JavaScript?

StevenRasmussen avatar Jan 25 '18 22:01 StevenRasmussen

Looks like you can do 'this.picker.wrapper.open()'. Not sure if this is the supported way though. Can anyone confirm this?

StevenRasmussen avatar Jan 25 '18 22:01 StevenRasmussen

any above doesn't work.tried ref ,datepickerDialog,that wrappr.open thing,ref.show function nothing works. issue still exist

jashacharya avatar Jun 23 '20 13:06 jashacharya

@jashacharya Use the open/onClose/onOpen props.

oliviertassinari avatar Jun 23 '20 14:06 oliviertassinari