I am using Primefaces Datatable to show the data, i have used draggablerows and trying to save/persist the reordering of the rows in the backing bean
with
<p:ajax event = onRowReorder listener=#{bean.onRowReorder}/>
I can get the from and to indexes from the event. But, I was not able to persist the row reordering:
<p:dataTable value="#{EmployeeHandler.model.employees}" var="employee" draggableRows="true">
<p:ajax event="rowReorder" listener="#{EmployeeHandler.onRowReorder}"/>
<p:column>
<h:outputText value="#{employee.id}"/
</p:column>
<p:column>
<h:outputText value="#{employee.firstName}"/
</p:column>
<p:column>
<h:outputText value="#{employee.lastName}"/
</p:column>
</p:dataTable>
I tried
public void onRowReorder(ReorderEvent event) {
event.getFromIndex();
event.getToIndex();
// I want to iterate through all the rows and save the new order of the employees list
}
How to Persist Rows after Reordering in backing bean
Lots of discussion about this identical question here https://stackoverflow.com/questions/546 ... cking-bean, let's try to keep it in one place
-
- Information
-
Who is online
Users browsing this forum: No registered users and 30 guests