Update a datatable row using the rowKey #3383
-
I want to ajax update a single datatable row, given the rowKey, when the data changes on the server side. I can already update the whole table, that works no problem, but the table contains lots of data so ajax updating it is quite expensive. On the client side I can select the relevant tr with this, for example:
Is there a way of doing this on the server with PrimeFaces.current().ajax().update( ... ) ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You can use <p:commandButton ... update="@form:visitTable:@row(#{rowIdx})" /> See the docs: https://primefaces.github.io/primefaces/14_0_0/#/core/searchexpression?id=primefaces-additional-keywords |
Beta Was this translation helpful? Give feedback.
-
I couldn't get @Row to work in the java backend, but I managed to get something working - which involves 2 roundtrips and involves embedding all cells within the table within a panelGroup with a particular css class for each row. For example, the css class might be "row-dynamic-update-{rowId}" This is the workflow:
What would be really nice would be a way of using the rowKey to reference the data in primefaces. So, for example this could work from the backend: PrimeFaces.current().ajax().update("@Form:dataTable:@Rowkey(myRowKey)"); Even if @Row could work from the backend it would be helpful. Phew ... ! |
Beta Was this translation helpful? Give feedback.
I couldn't get @Row to work in the java backend, but I managed to get something working - which involves 2 roundtrips and involves embedding all cells within the table within a panelGroup with a particular css class for each row.
For example, the css class might be "row-dynamic-update-{rowId}"
This is the workflow: