How to only change the visible checkboxes of a datatable?

1

Problem situation, suppose we have a datatable in primefaces with the following characteristics:

  • The first column instead of the title has a checkbox with the label all .
  • All lines in this first column also have a checkbox (and this checkbox is related to an attribute of the class being used to populate the table. For example, if they are cars, besides the class have the name and value of the car, for example, would also have a selection field, which would indicate that car is selected or not, attached to a property of the class being used to populate the table.)
  • All but the first column has a contains filter to filter results.
  • The table may have multiple pages.

What would be the easiest and most effective way to do that by pressing the all checkbox, only the checkboxes that are visible (that is, the ones on the current page, already applying the filters or not) are selected (and therefore also its selection property in the corresponding bean)?

    
asked by anonymous 09.06.2014 / 03:26

1 answer

2

As you put the primfaces tag, I assume you are using it. In the demo of primefaces itself you have what you are asking.

Look for the table that is using checkbox and see.

Primefaces DataTable

    
04.07.2014 / 15:23