1

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Seems like this will de-select all already checked box no matter the page. Is it possible to just specifically de-select the checkbox in the header?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.