如何更改 Antd 表中的排序顺序?

发布于 2025-01-18 15:07:30 字数 257 浏览 2 评论 0原文

我想更改ANTD表中的排序顺序。现在,在初始化组件之后,排序以“单击进行排序”开始,然后切换到下降,最后是无。

我的目标是从上升 - &gt更改订单;下降 - >无需降序 - >上升 - >无。如果没有将工具提示消息和请求变为反向的情况,是否有可能?

我已经尝试使用sortDirectionsdefaultSortorder,但它们似乎并没有解决我的问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

触ぅ动初心 2025-01-25 15:07:30

我看了ANTD文档 - 版本4.19.4-和sortDirections在我的情况下。

const CustomTable = () => {
  const tableColumns = columns.map((item) => ({ ...item }));

  return (
    <Table
      sortDirections={["descend", "ascend"]}
      columns={tableColumns}
      dataSource={data}
    />
  );
};

这是一个沙盒: https://codesandbox.io/sandbox.io/santd-table-s/antd-table-- sorting-order-9Uuv80

我没有包含工具提示,但是您可以看到该顺序是 descing apping and em> and none

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文