I've trying to implement a date range filter in my Ant Design's table using this code here but no success so far. It looks like isn't working on newer versions of Ant Design.
Someone had successfully implemented it? How?
Find filterDropdown method in https://ant.design/components/table/#header
Replace <Input ... > with:
<DatePicker.RangePicker
style={{ marginBottom: 8, display: 'block' }}
value={selectedKeys[0]}
onChange={e => setSelectedKeys(e ? [e] : [])}
onPressEnter={() => {
confirm();
setSearchText(selectedKeys[0]),
setSearchedColumn(dataIndex);
}}
/>
Replace onFilter with:
onFilter: (value, record) => record[dataIndex] ?
moment(record[dataIndex]).isBetween(value[0], value[1], 'day', '[]') : "" ,
(optionally) replace render with:
render: text => moment(text).format("DD/MM/YYYY")
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