Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table checkbox selection ignores filtering #5220

Closed
coffeymatt opened this issue Feb 26, 2018 · 15 comments
Closed

Table checkbox selection ignores filtering #5220

coffeymatt opened this issue Feb 26, 2018 · 15 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@coffeymatt
Copy link

coffeymatt commented Feb 26, 2018

**I'm submitting a ...

[x ] bug report

Current behavior
If you use table selection (https://www.primefaces.org/primeng/#/table/selection) and have a checkbox header to select all (p-tableHeaderCheckbox), selecting all will include filtered out rows and rows from other pages.

Expected behavior

When you select all, it shouldn't include in the selected data array, data that has been filtered out or is on another page. It should only select what's visible on the screen.

Minimal reproduction of the problem with instructions

Create a table with two pages of data and a basic filter and multi row selection with checkboxes as per the docs. Note that when you select all, items you have filtered out or are on another page are included in the selection.

What is the motivation / use case for changing the behavior?

It's the logical expected behaviour, only to select what you can see.

  • Angular version: 5.2.6

  • PrimeNG version: 5.2.0

  • Browser: all

  • Language: [all]

@mousedown
Copy link

+1

@mhaisley
Copy link

mhaisley commented Mar 5, 2018

Having the exact same issue.
Is there a temporary fix that can be implemented with table selection?

@mousedown
Copy link

mousedown commented Mar 6, 2018

You would have to keep track of the current filters selected with onFilter() then manually remove them from the array set with [(selection)]=

@arjendevries
Copy link

I'm having a similar issue. When I check the p-tableHeaderCheckbox I get all on page (in my case 20) and next i nav through pages I can select one off items and it adds to my total number of selected items. However as soon as I check the select all on page again it blows away my selected items and shows me only those 20. Same thing if i select all on page 1, go to page 2 and select all again...page 1 stuff is gone.

@gonzalodevops
Copy link

Same behavioral issues here ... totally confusing feature if it does not work fully integrated with paging and filters.

@cagataycivici cagataycivici self-assigned this Mar 28, 2018
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Mar 28, 2018
@cagataycivici cagataycivici added this to the 5.2.4 milestone Mar 28, 2018
@cagataycivici cagataycivici changed the title Table checkbox selection, select all not taking into account of filters and page Table checkbox selection ignores filtering Mar 28, 2018
@mousedown
Copy link

Anyone confirmed this in 5.2.4? The select all checkbox is now not responding for me.

@chfiras
Copy link

chfiras commented Apr 13, 2018

it's fixed in 5.2.4

@chfiras
Copy link

chfiras commented Apr 13, 2018

after filtering and select all with checkbox you cannot deselect all with the checkbox again
that issue appear in the version 5.2.4

@e01010100
Copy link

In 5.2.4 the behavior appears to be different depending on if [headerCheckboxToggleAllPages] is "true" or "false". If true then the bug is still there and the check-all checkbox ignores filtering. If false, then the check-all checkbox appears to work correctly (clearing previously selected options and selecting all currently filtered options).

However, I am using the deprecated datatable: https://www.primefaces.org/primeng/#/datatable/selection

@JordanDurieux
Copy link

What should be the behaviour for the following situation :

  1. Select 4 rows
  2. Filter to display only 2 of the 4 rows selected
  3. => the 2 hidden rows should remain selected or not ?

@chfiras
Copy link

chfiras commented Apr 19, 2018

the 2 hidden rows not selected

@JordanDurieux
Copy link

@chfiras p-table keep the selection, no matter what is filtered

@e01010100
Copy link

What should be the behaviour for the following situation :
Select 4 rows
Filter to display only 2 of the 4 rows selected
=> the 2 hidden rows should remain selected or not ?

In that case the 4 rows should remain selected as you took no extra action.

  1. Select All rows (4)
  2. Filter to display only two rows (both of which are still selected, including the two you can no longer see)
  3. Deselect all rows (0 now selected)
  4. Select all rows while filtering is still applied (2 rows selected)
  5. Clear filtering - all rows now shown (2 rows still selected)

@mousedown
Copy link

mousedown commented Apr 22, 2018

you took no extra action

So the p-table doesn't actually maintain the selection if applied AFTER select all is selected, only before.
To do this, we must keep track when 'select all' checkbox is applied, then deselect all, then select all programatically when the filter changes with via onFilter, or put the onus on the user.

Select all now works and respects filtering if used after filter, however I there is now a second (expected) feature for filtering to respect select all.

There is also another bug associated here. Check box is disabled, following a select all on a filtered collection.

  • Apply Filter
  • Select All
  • Not the select All checkbox is disabled.

@FTello31
Copy link

FTello31 commented Jun 8, 2020

I handled it using this.dataSource.filteredData instead of this.dataSource.data.
https://stackblitz.com/edit/angular-biuy85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

10 participants