-1

i have found example of dnd on Ant.design website, but how can I make only certain rows dragable?

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

Update: I have tree structure (datasource with children). My goal is to dnd first level children inside parent (0 level data).

Update2: I managed to achieve it by changing:

  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, 0, dragRow]],
    },}}

  }),
)

};

user3046616
  • 29
  • 1
  • 6

1 Answers1

0

you can edit the beginDrag in the rowSource constant. Example

const rowSource = {
  beginDrag(props, monitor, component) {
    dragingIndex = props.index;
    return {
      index: props.index,
    };
  },
  canDrag(props){
    return props.children[0].props.record.age === 32
  }
};
Julio Javier
  • 162
  • 4
  • Thank You for your help. My problem is more complex because I have expandable tree data and I want to dnd first level children inside parent. Probably I have to build Table from scratch... – user3046616 Jan 14 '20 at 12:41