ngx-datatable: Checkbox select all not working properly with server-side pagination
I’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Using server side pagination and checkbox selection:
- go to page 1, select some items
- got to another page, push the “select all” checkbox
Current behavior
- it will select only the elements in the new page, removing the selection of the previous page
Expected behavior
- all the elements of the new page should be added to the selection, without removing the previously selected items
Reproduction of the problem
The reproduction steps are listed above.
Also, I need to specify that this is NOT related with https://github.com/swimlane/ngx-datatable/issues/874 , since I set the [rowIdentity] function and the single selection works fine even across different pages (except for the “select all” button).
Please tell us about your environment:
Angular CLI: 1.7.3
Node: 8.9.1
OS: linux x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.6.2
webpack: 3.11.0
-
Table version: 0.8.x
-
Angular version: 5.2.9
-
Browser: Google Chrome 65.0.3325.181 (Official Build) (64-bit)
-
Language: TypeScript 2.6.2
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 11
- Comments: 15
Found a solution using custom checkboxes, and custom select all function. And an object that stores which pages has selected all.
Custom checkbox column taken from http://swimlane.github.io/ngx-datatable/#chkbox-selection-template Here i removed let-allRowsSelected=“allRowsSelected” let-selectFn=“selectFn” From template, and hooked up my own checkbox function.
With this select all function (CompanyListPaginated are my rows, for the page)
Remember to remove selectAll page index when unselecting a single item.
However i really wished i didnt have to handle this manually. One of the reasons i chose ngx datatable is that I wanted to avoid making custom select/select all functions.
I have the same problem with server-side pagination, the actual problem is, data object identity mismatch. In order to solve this problem use
[rowIdentity]="getId"in<ngx-datatable>and declaregetIdfunction in TS.