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

Can't override <Table/> "Select All" checkbox when paginated #25747

Open
1 task done
ChambreNoire opened this issue Jul 22, 2020 · 7 comments
Open
1 task done

Can't override <Table/> "Select All" checkbox when paginated #25747

ChambreNoire opened this issue Jul 22, 2020 · 7 comments

Comments

@ChambreNoire
Copy link

ChambreNoire commented Jul 22, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

I have an Ant Design table with sorting, selection and pagination. By default (if I understand it correctly), Antd Table selection works on a per-page basis. If you click the 'Select All' checkbox in the selection column header, Antd will select all the rows on the current page but if you then change page, both the rows and header will revert to a unchecked state. The selection is not lost because if you then go back to the previous page, the rows and header are all checked.

So I wanted to change this so that 'Select All' really selects all the rows of the table regardless of pagination. I found a few github issues in which recommended simply managing the selectedRowKeys array onSelect and onSelectAll functions oneself. I did this and now my selection works as expected...

However...

The "select all" checkbox in the selection column header still functions in terms of the page rows. So for example if I'm on the first page and "Select all" then deselect one of the rows, the "select all" checkbox is in the intermediate/partial state as expected. However if I then go to the next page, all rows are checked as expected and so is the "select all" checkbox in the header. For this selection to make sense functionally it would need to remain in the intermediate/partial state. It needs to reflect the selection over the entire dataset and not just the current page.

What is expected?

To be able to override the state of the "Select all" checkbox to find a "selection over entire paginated dataset" scenario.

What is actually happening?

Nothing. Can't find any info on how to do this!

Environment Info
antd 4.4.3
React 16.11.0
System Windows 10
Browser Google Chrome 83.0.4103.116

This is a bit of a deal-breaker for us...

@ChambreNoire ChambreNoire changed the title Can't override <Table/> "Select All" control when paginated Can't override <Table/> "Select All" checkbox when paginated Jul 22, 2020
@cuobiezi
Copy link

cuobiezi commented Jul 26, 2020

Dear Team

I guess I got this problem , I've readed the code , there are two props in useSelection data & pageData, when we trigger SELECTION_ALL will map with data not pageData .
As the code design , map with pageData is better then map with data in SELECTION_ALL, Maybe this is a bug. please check & confirm it.
If the team agree me .Please assign it to me .

Thx & Best Regards

@07akioni
Copy link
Contributor

Dear Team

I guess I got this problem , I've readed the code , there are two props in useSelection data & pageData, when we trigger SELECTION_ALL will map with data not pageData .
As the code design , map with pageData is better then map with data in SELECTION_ALL, Maybe this is a bug. please check & confirm it.
If the team agree me .Please assign it to me .

Thx & Best Regards

In my memory, SELECTION_ALL is trigger by a dropdown menu. Header checkbox alway reflects pageData

@cuobiezi
Copy link

Dear Team
I guess I got this problem , I've readed the code , there are two props in useSelection data & pageData, when we trigger SELECTION_ALL will map with data not pageData .
As the code design , map with pageData is better then map with data in SELECTION_ALL, Maybe this is a bug. please check & confirm it.
If the team agree me .Please assign it to me .
Thx & Best Regards

In my memory, SELECTION_ALL is trigger by a dropdown menu. Header checkbox alway reflects pageData

Yes U R right , I need to read it careful

@07akioni
Copy link
Contributor

Maybe you can add a getHeaderCheckboxProps for that. PR welcomed.

@JohnnyHandy
Copy link

Yes I have the same issue... as @07akioni mentioned, a getHeaderCheckboxProps would solbe the problem I guess. Since I cant controll the check all checkbox state, I am gonna have to use another component rather than the Table one with a controlled checkbox

@JohnnyHandy
Copy link

I found this workaround where you can override the check all checkbox using the columnTitle property inside the rowSelection prop

@ChambreNoire
Copy link
Author

I found this workaround where you can override the check all checkbox using the columnTitle property inside the rowSelection prop

Gahh I should have thought of that! Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants