'AG Grid de-select 100 rows
I am trying to do the following , select 100 rows and de-select the same 100 rows in AG Grid. Selecting 100 rows ( filtered/not) is working with the below
HTML :
<ag-grid-angular
style="width: 100%; height: 550px;"
class="ag-theme-material"
[rowData]="rowData"
[columnDefs]="columnDefs"
[enableSorting]="true"
[enableFilter]="true"
enableColResize="true"
[context]="mycontext"
pagination="true"
[rowSelection]="'multiple'"
[getRowNodeId]="getRowNodeId"
(selectionChanged) = "onSelectionChanged($event)">
</ag-grid-angular>
TS :
{
headerName: '', field: 'random', width:50,
headerCheckboxSelection: true,
headerCheckboxSelectionFilteredOnly: true,
suppressRowClickSelection: true,
checkboxSelection: true}
onSelectionChanged(params){
var selected = params.api.getSelectedRows().length;
var totalRows = params.api.getDisplayedRowCount()
console.log('selected',selected,'totalRows',totalRows)
if(selected === totalRows){
params.api.deselectAll()
for (var i=0 ; i<=100;i++){
params.api.getDisplayedRowAtIndex(i).setSelected(true)
}
}
}
But on the page when I try to uncheck checkbox header it is not hppening , Onselectionchanged triggered again and the same function executes , I am not able to clear the existing selection. Any help please ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
