245
Views
5
Comments
how to select all records checkbox in all pages ?
Application Type
Reactive

Hi Everyone,

1, when the check box in the header is selected it should select all the records


2, All records on all the pages, how to do that?

Regards,

Asik

2022-08-03 04-32-50
Ravi Punjwani

On your header checkbox's OnChange event, run a loop through all the records on your data source aggregate variable (not only the current page records), and toggle the check box variable's value in the loop for each record.

However, this is possible only when you've client-side paging. If you've optimized your code for server side paging, you'll need to add appropriate logic to fix checkbox value on the PageChanged event also.

UserImage.jpg
Shaik Asik

hi Ravi Punjwani,

Thanks For the response. I already did selected all records but now I want  when I click the page 2 checkbox  record also  selected . 

below attach logic screenshot

Regards,

Asik

2022-08-03 04-32-50
Ravi Punjwani

Hi Shaik,

Please suggest if you're:

  1. fetching the records all at once on page load, or
  2. fetching records for only one page then fetch more records on page changed?

In the first scenario, you should have all your pages already preselected checkboxes when you change paging.

In the second scenario, add the OnDataFetched event on your data source, and change the value of each record's checkbox variable and set it with the header checkbox value. This will make sure the current header value reflects all the newly fetched records after paging.

UserImage.jpg
Shaik Asik

Hi Ravi Punjwani ,

the second scenario works but one problem 


let i explain 


select all records on all pages is selected perfectly it works . then  now I want deselect one record on page 2, then I go to  3 pages, now I return to the pages 2, the deselect one record it automatically  selected 

regards ,

Asik

2022-08-03 04-32-50
Ravi Punjwani

Saving a state of the page after moving won't be possible with server side paging.

If that is a hard-requirement, you need to switch to client-side paging, and it will be much easier for you to maintain state of the current selected items. The state would be maintained until you refresh the page in browser.

Keep in mind that client side paging can have performance issues on server and browser if huge data is processed altogether. Usually with a couple of hundred records, it shouldn't matter much. You know what would work best for your use-case.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.