I want to change the sorting order in Antd's table. Right now, just after the component is initialized, sorting starts with "Click to sort ascending", then switches to descending and finally to none.
My goal is to change the order from ascending -> descending -> none to descending -> ascending -> none. Is it possible without changing tooltip messages and requests to their reverse?
I've tried using sortDirections
and defaultSortOrder
but they don't seem to solve my problem.
CodePudding user response:
I had a look at the antd docs - version 4.19.4 - and sortDirections
works in my case.
const CustomTable = () => {
const tableColumns = columns.map((item) => ({ ...item }));
return (
<Table
sortDirections={["descend", "ascend"]}
columns={tableColumns}
dataSource={data}
/>
);
};
Here's a Sandbox: https://codesandbox.io/s/antd-table-sorting-order-9uuv80
I didn't include the tooltip but you can see the order is descending, ascending and none.