Tahsin Abrar
Tahsin Abrar

Reputation: 920

Angular table-sort and drag and drop table row conflict

I am using angular table-sort and angular drag-drop in my project. When I am dragging a row and trying to drop it to another row, then table sort forcefully sort the rows to their previous position.

If I remove the table sort directive ts-repeat, then drag and drop works perfectly. I also need default table column sorting "Age" ascending. I have made an example on plunker for better understanding. https://plnkr.co/edit/pHlTufpayFAB4he8bN6y

So, how to prevent table-sort when drag and dropping a row?

Can anyone help me solving this issue? I would really appreciate this. Thanks in advance.

Upvotes: 7

Views: 5013

Answers (3)

Cagatay Civici
Cagatay Civici

Reputation: 6504

PrimeNG Table offers row reordering with drag drop, you need upcoming 5.2.1 though.

https://www.primefaces.org/primeng/#/table/reorder

Upvotes: 1

Sanjib Saha
Sanjib Saha

Reputation: 31

You can try by using Angular ui-sortable instead of angular drag-drop. I think it will work for you.

Upvotes: 2

fodma1
fodma1

Reputation: 3535

I think you should just get rid of ts-repeat, and only sort the data initially (in your service/controller). It's not a bug, it's a feature. Imagine, that you remove and then re-add an element to a table, which is sorted. You want it to keep sorted, right?

Upvotes: 6

Related Questions