1
votes

In ngx-datatable,how to check/uncheck header column(headerCheckboxable)( column with a checkbox) on click of button.

When I click on the cancel button, my all rows get deselected but header checkbox remains selected.

1
Can you please share a Minimal Complete Verifiable Example replicating this issue?SiddAjmera

1 Answers

1
votes

You could reset the selected property of your ngx-datatable. This will deselect all rows including the header checkbox. Here is a small code snippet to demonstrate this:

@ViewChild('mytable') table: DatatableComponent;

selectedRows = [];

onSelect({ selected }) {
    this.selectedRows.splice(0, this.selectedRows.length);
    this.selectedRows.push(...selected);
}

onSomeActionToDeselectAllRows() {
  this.onSelect({selected: []});
  this.table.selected = [];
}
<ngx-datatable #mytable
  [selected]="selectedRows"
  (select)="onSelect($event)">