react antd table react-sortable-hoc DraggableBodyRow 拖拽及禁用指定行拖拽

原文地址:基于antd树形表格table的拖拽排序效果实现 - 掘金 (juejin.cn)

思路片段:

const DraggableBodyRow: React.FC<any> = ({ className, style, ...restProps }) => {
    const index = customInfoList.findIndex(
      ({ order: _index }) => _index === restProps['data-row-key'],
    );
    // 头两行禁用
    if ([0, 1].includes(index)) {
      return (
        <tr
          className={className}
          // style={isDrag ? { cursor: 'move', opacity, ...style } : { ...style }}
          // data-handler-id={handlerId}
          {...restProps}
        />
      );
    }

    return <SortableItem index={index} className={className} {...restProps} />;
  };

 

posted @ 2023-12-07 19:58  最好的年纪  阅读(344)  评论(0编辑  收藏  举报