Manoj Kumar
Manoj Kumar

Reputation: 61

How can I implement Drag and Drop (Shuffling of rows) in Datatable of primefaces?

I am using Primefaces DataTable to display content in a grid. I want to reorder these rows using drag and drop(shuffle), I have tried jquery sortable, it works only ones, after that I need to refresh the browser. Is there any way to implement that?

Thanks a lot

Upvotes: 2

Views: 3795

Answers (2)

Mathieu Castets
Mathieu Castets

Reputation: 6040

This feature is now available from PrimeFaces 5.0:

Usage is very simple by just enabling draggableRows option and also an optional rowReorder ajax behavior is provided getting a ReorderEvent with index information for flexibility.

Source : http://blog.primefaces.org/?p=3026

You can also have a look at the showcase here: http://www.primefaces.org/showcase/ui/data/datatable/reorder.xhtml

Upvotes: 3

siebz0r
siebz0r

Reputation: 20369

There is currently no way to have row-sorting with server side effects. You can achieve client side reordering using jQuery, but this is not stored on the server.

$('.ui-datatable tbody').sortable();

There is a discussion on the PrimeFaces forum.

There is also an issue about drag/drop capability in PrimeFaces' issue tracker. Note that the issue is closed as WontFix, so I guess you're out of luck.

Upvotes: 1

Related Questions