【问题标题】:Expanded Row is not Collapse in React and AntDesgin在 React 和 AntDesgin 中展开的行不折叠
【发布时间】:2021-08-04 17:32:36
【问题描述】:

我正在使用 Ant Design 表,其中我正在使用行扩展功能。我的查询是当我单击表格的任何行时,该行正在打开但不折叠回来。我只是希望以这种方式单击“+”图标,该行应该打开,如果单击“_”图标行应该折叠,如果上一行在单击下一行时打开,前一行也应该折叠。 ...请提供我提供的任何解决方案,我在其中实现了一半代码的链接.. 帮助将不胜感激....提前致谢。

enter code here

现场示例:https://codesandbox.io/s/eloquent-http-jxf1m?file=/src/App.js

【问题讨论】:

    标签: reactjs antd


    【解决方案1】:

    您可以检查 prev 和 next 是否相同,这意味着折叠。 否则就是展开。

    Working link

    const onExpand = (_, key) => {
    
      setExpandedKey((prev) => {
        const newKey = key.key;
        if (prev !== newKey) {
          return newKey;
        }
        return null;
      });
    };

    【讨论】:

    • 非常感谢您
    猜你喜欢
    • 2021-03-22
    • 2016-08-25
    • 1970-01-01
    • 2018-12-13
    • 2013-06-06
    • 2014-06-30
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    相关资源
    最近更新 更多