Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to custom datepicker actions lable?

<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale='zh-cn'>
        <DatePicker
            value={value ? dayjs(value) : null}
            ref={ref}
            {...other}
            onChange={value => {
                setOpen(!open)
                onChange(value.format('YYYY-MM-DD'))
            }}
            slotProps={{
                textField: {
                    InputProps: {
                        endAdornment: <InputAdornment position='end'>
                            {value && <IconButton onClick={() => onChange(null)}><CloseIcon/></IconButton>}
                            <IconButton onClick={() => setOpen(!open)}><CalendarMonthIcon/></IconButton>
                        </InputAdornment>
                    }
                },
                actionBar:{
                    actions:['clear']
                }
            }}
            open={open}
        />
    </LocalizationProvider>

hi,you can see i add actions for actionBar,the actions is array not object, so the clear action always display "clear" for me. but i am Chinese,so i want display "清除" only for label,how to do it

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

jsx
import { LocalizationProvider, DatePicker, AdapterDayjs } from 'your-dependencies';

// ...

<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale='zh-cn'>
    <DatePicker
        value={value ? dayjs(value) : null}
        ref={ref}
        {...other}
        onChange={value => {
            setOpen(!open)
            onChange(value.format('YYYY-MM-DD'))
        }}
        slotProps={{
            textField: {
                InputProps: {
                    endAdornment: <InputAdornment position='end'>
                        {value && <IconButton onClick={() => onChange(null)}><CloseIcon/></IconButton>}
                        <IconButton onClick={() => setOpen(!open)}><CalendarMonthIcon/></IconButton>
                    </InputAdornment>
                }
            },
            actionBar:{
                actions:[{
                    label: '清除',
                    value: 'clear'
                }]
            }
        }}
        open={open}
    />
</LocalizationProvider>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading