Primfaces datatable selects all records in all pages problem

UI Components for JSF
Post Reply
sanjaymodha123
Posts: 7
Joined: 18 Feb 2011, 16:35

15 Jul 2011, 17:56

Primfaces datatable selects all records in all pages when I use selection mode as "multiple" but I need to select only those records which displayed on the current page. I am using select all checkbox but I want to change the behaviour of select all checkbox such that it selects only the records displayed on the current page as there are mulitple pages in the datatable.

I am using the following code in primefaces datatable

Code: Select all

<p:column selectionMode="multiple" />
Any suggestions.

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

16 Jul 2011, 12:46

This is either something you need to change yourself in the code of the datatable component, or file an issue and gather votes to give it higher priority in getting implemented. Still no guarantees then about when it will be implemented. If it is really important, buy enterprise support (I'm not affiliated to PF or Prime Technogy)

Cheers,

Ronald

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Jul 2011, 13:25

Do you think it should select only current page records?

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

16 Jul 2011, 15:10

If you ask me, I initially had no idea. My changes to multi-select (using shift) does select all items across all pages. Now I think of it, I do not know if that should be the case. GMail only selects the messages on the current pages but when you do, it gives you the option to actually select ALL items on all pages, but it should warn the user about this maybe...

SirTori
Posts: 2
Joined: 21 Jul 2011, 12:28
Location: Germany

21 Jul 2011, 12:55

I personally would expect only the shown elements to be selected. But i too understand that there are use cases where selecting all elements on all pages would be useful. Therefor from a usability point of view something along the line what kukeltje mentioned would be a good compromise for bringing the user expactations and the mentioned use cases together. Or at least the possibility to configure if all or the currently shown items should be selected would be nice.

related to this is a problem i found recently but couldn't find any statements (if it's supposed to be a bug or intentionally like this):
When I check the checkbox in the header to select all items and then uncheck single rows (items) to exclude them i notice 2 things.
1. The Checkbox in the header is still checked -> i would expect this to be unchecked, because i unchecked at least one row and therefor no longer all items are selected (which is indicated by the header-checkbox)
2. The bound array in the backing bean still holds all elements. I would expect that the unchecked rows (items) are not included in this array (i didn't look in the implementation, but i guess this could come from the header-checkbox still being checked)

I also noticed this behavior in the labs-showcase. In the normal showcase the first point also exists, but the unselected rows are excluded from being shown, when "view" is clicked. So i guess the second point may be a bug?

regards,
Tori
Primefaces 3.0 M2 - Glassfish 3.1


SirTori
Posts: 2
Joined: 21 Jul 2011, 12:28
Location: Germany

21 Jul 2011, 13:21

Thanks.
I searched for dataTable, so no wonder i couldn't find the first one...
Primefaces 3.0 M2 - Glassfish 3.1

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

21 Jul 2011, 14:03

DataTable should select only displayed rows and not all rows. That's for sure! Selection of all rows is far away from user expectation and from all use cases I know. I was working in various projects with multi selectable datatables (no PrimeFaces) and multi selection was always applied to the displayed rows only. With PrimeFaces I have got assigned issue in our issue tracker regarding selection of all rows and have to fix this issue by datatable hacking.

I allow me one recommendation yet. I think, it would be great if PrimeFaces team would ask us before they make any decisions regarding to some doubt behaviors (like this one). PF community is very big, many people work in various business projects with tausends of use cases and have much experience.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests