When I set selectionMode="multiple" on a column I get a checkbox in the table's header. It is used for selecting all rows. I noticed that if the table is paginated and there is more than one page, selecting all rows only selects the ones on the current page. Is there a way to select the total number of rows?
You can use onHeaderCheckboxToggle to select whole dataset.
Thanks for your reply. I tried to do that it indeed all rows got selected but then the checkbox in the head is shown as unchecked. Unfortunately I couldn't reproduce the issue in Plunker because I have troubles importing PrimeNG into it. Do you have a barebone Plunker + PrimeNG, which I can try to play with?
@dzhavat - I am experiencing the same issue. I believe the issue is with the header checkbox checked binding:
<p-dtCheckbox *ngIf="col.selectionMode=='multiple'" (onChange)="toggleRowsWithCheckbox($event)" [checked]="allSelected" [disabled]="isEmpty()"></p-dtCheckbox>
As you can see, it relies on the allSelected function, which first checks whether the dataToRender and selection lengths are the same. Since the table is paged and you have manually added all data to the selection, the selected length will never be equal to the dataToRender length, so this will always return false--causing the head checkbox to remain unchecked. I believe my submitted PR should fix the issue.
get allSelected() {
let val = true;
if(this.dataToRender && this.selection && (this.dataToRender.length == this.selection.length)) {
for(let data of this.dataToRender) {
if(!this.isSelected(data)) {
val = false;
break;
}
}
}
else {
val = false;
}
return val;
}
@saverett Thanks for your effort. You solution will definitely help me. Hopefully it will be merged into the component and we don't have to worry about it any more :)
I believe this issue should be re-opened until the HeaderCheckbox behaves correctly when selecting the entire dataset (which I believe PR #1412 should fix).
I've merged the PR that brings compatibility with onHeaderCheckboxToggle.
I've opened a PR for an improvement on the original fix for this issue. See #2424.
Shouldn't we have an option whether we want all records should be select or just the current page data should be selected?
I have similar issue. But in case I want it to select all records from current page only.
Any help is much appreciated.
Thanks.
Shouldn't we have an option whether we want all records should be select or just the current page data should be selected?
I have similar issue. But in case I want it to select all records from current page only.
Any help is much appreciated.
Thanks.
hi pradeep did you found the solution ?? i am looking for selecting all the records in the current page,
can any one please help me
Hi,
I created a workaround for this. On select all checkbox click, I calculate
the current page record and push it in selected values array.
On Thu, 21 Nov 2019, 20:18 angular user, notifications@github.com wrote:
Shouldn't we have an option whether we want all records should be select
or just the current page data should be selected?
I have similar issue. But in case I want it to select all records from
current page only.
Any help is much appreciated.
Thanks.hi pradeep did you found the solution ?? i am looking for selecting all
the records in the current page,can any one please help me
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/primefaces/primeng/issues/1206?email_source=notifications&email_token=ABPTOVD647IWTQPUIHC25FLQU2NSBA5CNFSM4CVGPS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2PAIQ#issuecomment-557117474,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABPTOVGUJZMQTBFIKIHAYS3QU2NSBANCNFSM4CVGPS5Q
.
Hi, I created a workaround for this. On select all checkbox click, I calculate the current page record and push it in selected values array.
…
On Thu, 21 Nov 2019, 20:18 angular user, @.*> wrote: Shouldn't we have an option whether we want all records should be select or just the current page data should be selected? I have similar issue. But in case I want it to select all records from current page only. Any help is much appreciated. Thanks. hi pradeep did you found the solution ?? i am looking for selecting all the records in the current page, can any one please help me — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1206?email_source=notifications&email_token=ABPTOVD647IWTQPUIHC25FLQU2NSBA5CNFSM4CVGPS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2PAIQ#issuecomment-557117474>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPTOVGUJZMQTBFIKIHAYS3QU2NSBANCNFSM4CVGPS5Q .
hi thanku, how to get current page records ??
Most helpful comment
Shouldn't we have an option whether we want all records should be select or just the current page data should be selected?
I have similar issue. But in case I want it to select all records from current page only.
Any help is much appreciated.
Thanks.