Primeng: Row reordering with DragDrop for TurboTable

Created on 21 Jun 2016  路  38Comments  路  Source: primefaces/primeng

Hi,
One of the important functionality of datatable could be dragging and dropping rows within table.

Even though draggable and dropable component is available and example shows how to drag and drop from outside into datatable as below,

http://www.primefaces.org/primeng/#/dragdrop

There is no example or feature telling about dragging and reordering row within datatable like below example.

http://blog.primefaces.org/?p=3026
http://www.guriddo.net/demo/guriddojs/integrations/drag_drop_rows/index.html

Is it possible? if so, could you please provide code for it?

new feature

Most helpful comment

Checkmate!

reorder

All 38 comments

I would love to see this feature also

+1

+1

We need this functionality as well. We are currently combining ng2-dnd with p-datatable. However, it doesn't work as nice because as you drag [value] keeps getting updated nonstop and all the rows flicker back and forth. The only way to control it is to specify [rowTrackBy] function to be () => {}. This was present in 1.1.1, but was removed in 1.1.3.

+1

+1

+1

would beer someone to add this.

+1

+1

+1
any update on this request? maybe an estimated release date? need it badly.

+1

@taivu how much beer?? :beers:

+1

My issue was similar, I had to drag a row from table A and drop into a row of table B.
Managed to do this with ng-template, but it would be really nice to see an out-of-the-box funcionality doing this.

Upvoted. Need this.

+1

+1

I needed user to be able to reorder rows in the datatable by dragging. I have implemented it with ng2-dragula directive:
https://alligator.io/angular/drag-drop-ng2-dragula/
It has worked out-of-the-box and even the transition graphics are looking fine. Perhaps this can help somone out.

@akolybelnikov hi, ur post is really helpful for pure html tag situation, but i want to know if i can integrate dragula with primeng's data-table scenario, just like this post(https://github.com/primefaces/primeng/issues/2209), would you like to help on this? thanks in advance.

@arwindgao check this plunkr out:
https://embed.plnkr.co/Mivcv5/
I'm applying the dragular directive on the primeng pDatatable element and the rows can be reordered by drag and drop in the same table. Hope this helps.

It's works!!! Thanks!!! @akolybelnikov

+1

Thanks so much @akolybelnikov! Your Plunker is genius!

One quick note about @akolybelnikov's plunker, after I implemented the solution, my app failed it's aot build. The "bag" declared in the primeNG table doesn't have a value within the typescript file, and Angular didn't like that.

For me, the solution was just to not pass the bag into primeDragula. It doesn't seem to need it:
<p-dataTable [value]="rows" [tableStyle]="{ 'table-layout': 'auto' }" primeDragula [dragulaModel]="rows" [dragulaOptions]="{ childContainerSelector: 'tbody', initAfterView: true }" #datatable>

I hope that helps someone.

+1

+1

+1

+1

+1

+1

+1

We'll try this for new TurboTable targeting 5.2.0-RC2

Moved to RC3 as we need to release RC2 asap.

Checkmate!

reorder

Niiiiiiice

For those who are interested you can make the entire row draggable (not just the handle) by applying the handle directive to the actual cell.

      <td *ngFor="let col of columns" pReorderableRowHandle>
        {{rowData[col.field]}}
      </td>

Any hook for handling reorder like onDragEnd? Can't find anything in the docs

Also is it possible to pass item property as pReordableRow? Tried multiple combinations but with no luck.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cagataycivici picture cagataycivici  路  36Comments

sourdoth picture sourdoth  路  34Comments

JakeSummers picture JakeSummers  路  29Comments

mohan1304 picture mohan1304  路  37Comments

Vegim picture Vegim  路  30Comments