ngx-datatable icon indicating copy to clipboard operation
ngx-datatable copied to clipboard

How do i make all checkbox checked/unchecked from externally?

Open rahulmistry25425 opened this issue 6 years ago • 2 comments

I am having ngx datatable inside other ngx datatable like parent and child, how can i make selected all checkbox of child datatable from parent datatable on change of checkbox.

While digging into ngx-datatable checkbox found that its possible by using allRowsSelected and selectFn properties, but how can i call it from outside datatable.

<ng-template #headerTemplate ngx-datatable-header-template let-value="value" let-allRowsSelected="allRowsSelected" let-selectFn="selectFn">
<input type="checkbox" [checked]="allRowsSelected" (change)="selectFn(!allRowsSelected)" />
</ng-template>

Here is the screenshot 2018-10-17_150942

rahulmistry25425 avatar Oct 17 '18 09:10 rahulmistry25425

You must remember that ngx-datatable uses onPush changeDetection, so you should always work with immutable operations to return a new variable reference, like: this.selected = [... this.rows]; This should select all your rows. To unselect all, just clear the selected variable: this.selected = [];

d10n4t4n avatar Mar 11 '21 16:03 d10n4t4n

@dionatan-g that really helped, thanks!!

Atharva-Deshmukh avatar Apr 01 '24 06:04 Atharva-Deshmukh