Antd表-条件可拖动行渲染

我已经在Ant.design网站上找到了dnd的示例,但是如何使某些行只能拖动?

https://codesandbox.io/s/9uq4r

更新:我具有树结构(带有子级的数据源)。我的目标是在父级中找到一级子级(0级数据)。

Update2:我设法通过更改来实现:

  moveRow = (dragIndex,hoverIndex) => {
const { data } = this.state;
const dragRow = data[0].children[dragIndex];

this.setState(
  update(this.state,{
    data: {0: {
      children: {
      $splice: [[dragIndex,1],[hoverIndex,dragRow]],},}}

  }),)

};

wangkai5260929 回答:Antd表-条件可拖动行渲染

您可以在beginDrag常量中编辑rowSource。例子

const rowSource = {
  beginDrag(props,monitor,component) {
    dragingIndex = props.index;
    return {
      index: props.index,};
  },canDrag(props){
    return props.children[0].props.record.age === 32
  }
};
本文链接:https://www.f2er.com/2776925.html

大家都在问