Wrong values updating datatable with draggable rows

UI Components for JSF
Post Reply
LPV
Posts: 14
Joined: 17 Mar 2014, 11:50

27 May 2015, 12:30

When using a datatable where the rows are text after changing rows order the values are updated correctly.

Example:

Code: Select all

<p:dataTable id="dt_list" value="#{bean.selectedAt}" var="at" draggableRows="true" rowIndexVar="row">
    <p:ajax event="rowReorder" listener="#{bean.onRowReorder}" />
      <p:column>
         <h:outputText value="#{at.lk_name_at}"/>
        </p:column>
         <p:column>
            <h:outputText value="#{at.lk_number_at}"/>
        </p:column>
     </p:dataTable>
But when the rows have input fields the values are not updated correctly. The list in the backing bean gets all mixed up.

Example:

Code: Select all

<p:dataTable id="dt_list" value="#{bean.selectedAt}" var="at" draggableRows="true" rowIndexVar="row">
    <p:ajax event="rowReorder" listener="#{bean.onRowReorder}" />
    <p:column>
      <p:inputText id="lk_name_at" value="#{at.lk_name_at}"/>
    </p:column>
     <p:column>
       <p:inputText id="lk_number_at" value="#{at.lk_number_at}"/>
     </p:column>
</p:dataTable>
Thanks

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

27 May 2015, 15:12

define 'gets all mixed up' ...

kugupta
Posts: 1
Joined: 13 Feb 2017, 10:09

13 Feb 2017, 10:17

I am facing similar issue. the problem after re-ordering is that the input text still contains old vale even after re-order. for example -

suppose id is outputtextand name field is inputtext -

Sample datatable before reordering:

--------------
|id | name |
--------------
| 1 | Data 1 |
| 2 | Data 2 |
| 3 | Data 3 |
| 4 | Data 4 |
--------------
and after reordering (moving 1-st row to 3-rd):

--------------
|id | name |
--------------
| 2 | Data 1 |
| 3 | Data 2 |
| 1 | Data 3 |
| 4 | Data 4 |
--------------

i.e. instead of having Data 1 in third row it still remains into the first row.

Do let me know if there is any workaround. i am using primefaces 6.0 version.

mikereem
Posts: 2
Joined: 16 Jan 2017, 10:47

13 Nov 2018, 17:29

I have the same issue using Primefaces 6.2. My model object has a boolean value, which can be updated by a checkbox in the datatable. If I reorder the list items, then the checkboxes will have the same values as before the reordering, however it should obviously follow the reorder. The worse thing is that it really switches the boolean values in the backing bean, so it is not just displays wrongly, but it does a wrong update.

mikereem
Posts: 2
Joined: 16 Jan 2017, 10:47

14 Nov 2018, 16:04

Anyone, who has the same issue, check this out for a workaround: https://stackoverflow.com/questions/339 ... ing-inputs

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests