I need an option in nglightning to checkall records in datatable. The link for the component is as following
In the header row I need an option to check all checkboxes in nglightning.
I tried [] or [()] data binding first but it did not work. Created an ugly solution. You may need to ask ng-lighting why data binding does not work in column template.
Here is the Plunker: https://plnkr.co/edit/zNrWb4Ui2LVXc5fJb1oY?p=preview
Code I added:
<ngl-datatable-column heading="" key="points">
<template nglDatatableHeading><input type="checkbox" (click)="toggleCheckAll()" /></template>
<template nglDatatableCell><input type="checkbox" class="child-chkbox" /></template>
</ngl-datatable-column>
toggleCheckAll(){
var chkboxes = document.getElementsByClassName('child-chkbox');
this.checkAll = !this.checkAll;
for(let i = 0; i < chkboxes.length; i++){
chkboxes[i].checked = this.checkAll;
}
}