Search code examples
drag-and-dropprimeng

prime-ng drag/drop in combination with reorder is not working


I am trying to work on a prime ng table with both drag/drop and reorder enabled.

I can only have one working at a time, but when I enable both functionalities only reorder works.

Looked at the source and looks like the drop event is consumed at the reorder. I have an working example at demo

Here if you remove the [pReorderableRow]="index"from "Available" table drag drop works into the "Selected" section.

Is there a way to have both reorder and drag/drop working together.

Thanks


Solution

  • try to bind this events in the table

    (onDragStart)="dragStart(product)" (onDragEnd)="dragEnd()"

    here's a sample

     <tr pDraggable="products" [pReorderableRow]="index" (onDragStart)="dragStart(product)" (onDragEnd)="dragEnd()">
    

    then at the typescript file try adding the function dragStart(product) and dragEnd()

      dragStart(data){
        //console.log(data);
      }
      dragEnd(){
        this.drop();
      }
    

    trigger the drop() method in the dragend() method.

    i tested it from the demo link you provide: [link]https://stackblitz.com/edit/primeng-tablereorder-dragdrop-demo?file=src/app/app.component.html