EasyUI Forum

General Category => EasyUI for React => Topic started by: chrwei on August 10, 2020, 07:19:13 AM



Title: DateBox Today button and the validator
Post by: chrwei on August 10, 2020, 07:19:13 AM
When using the calendarOptions validator, if today's date isn't valid, the Today button still lets you select today. 

in date components in other UI tookits, the today button only takes you to today in the calendar component, it does not select the date and populate the field.  this change would also fix this issue.


Title: Re: DateBox Today button and the validator
Post by: jarry on August 13, 2020, 02:53:39 AM
This issue has been solved. You can also set the 'buttons' to custom the button bar. Make sure to update to the newest version.
Code:
<DateBox
    ref={el => this.datebox = el}
    panelStyle={{ width: 250, height: 300 }}
    buttons={(value) => {
        return (
            <div className="datebox-button f-row" style={{ justifyContent: 'space-between', padding: '5 10px' }}>
                <LinkButton plain onClick={() => this.datebox.calendar.moveTo(new Date())}>Today</LinkButton>
                <LinkButton plain onClick={() => this.datebox.calendar.selectDate(new Date())}>Ok</LinkButton>
                <LinkButton plain onClick={() => this.datebox.closePanel()}>Close</LinkButton>
            </div>
        )
    }}
/>