When clicking the header selection checkbox, items of the current page are checked, but the header checkbox itself is not checked.
1 Answer, 1 is accepted
0
Accepted
Vessy
Telerik team
answered on 21 Nov 2022, 07:03 AM
Hi, Yiheng,
You can see how to implement a `selectAll` button which selection state is updated properly when all items are selected in the following demo. Can you compare it with your actual setup and see how they differ?
Hi Vessy, I've made that demo paginated, check the header selection button here https://stackblitz.com/edit/react-v7yj55?file=app%2Fmain.jsx
Vessy
Telerik team
commented on 23 Nov 2022, 08:53 AM
Thank you for the update, Yiheng. In the provided demo the header checkbox value is updated only if all items are selected, while in the paging scenario you are changing the selection only of the items on the first page. You can change the logic applied to the `headerSelectionValue` prop to update the header checkbox if any of the data items are checked (instead of if all items are checked) like follows:
Please note that with the sample above the header checkbox will remain checked event if you do not have selected items on the current page, but you have active checkboxes in some other pages. For example, in order to avoid this you can keep the headerChecked value in the state and update based on the items on the current page.