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.
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.
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)">