0

I am trying to use in-cell editing feature of datatable using Primefaces 3.1. The example shown on their site does not show how could I use "delete" functionality. When I click on "edit" image to make changes in the table row, it works. However, nothing happens when I click on the "delete" image.

I took the code from a working demo availble at PrimeFaces showcase. But, this demo also does not work for "delete".

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1250720
  • 363
  • 1
  • 5
  • 17

1 Answers1

1

However, nothing happens when I click on the "delete" image.

It is not clear what is "when I click on the delete image". In the Primefaces showcase there is no delete image (maybe you mix it with the cross icon, but this is for discarding changes).

I think you need to add delete functionality yourself, e.g. in a separate column (example as addition to the Primefaces showcase code):

<p:column>
  <h:commandButton value="Delete" action="#{tableBean.delete(car)}"/>
</p:column>

and in the backing bean:

public void delete(Car car) {
  carsSmall.remove(car);
}
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • thank you for your reply. I indeed mistook cross icon for delete functionality. Is there any other solution besides you suggested above to delete an entire row? – user1250720 Mar 05 '12 at 21:22
  • 1
    If you want to delete a single row, this is the easiest solution I know. If you want it more complicated, you could delete your row with the row index. Or bind your table to a backing bean table component ... – Matt Handy Mar 05 '12 at 21:27
  • @user: if you want to know about all ways to get the selected table row inside your bean's action method, check this: http://stackoverflow.com/questions/4994458/how-can-i-pass-a-parameter-to-a-commandlink-inside-a-datatable – BalusC Mar 06 '12 at 12:18