Bear
Bear

Reputation: 41

ag-grid checkboxSelection default value

I have an ag-grid with a simple checkboxSelection and would like to have some rows "checked" when loading the grid/data.

{
                headerName: ' ',
                colId: 'select',
                checkboxSelection: true,
                headerCheckboxSelection: false,
                width: 22,
                maxWidth: 22,
                suppressToolPanel: true,
                suppressMenu: true,
                suppressSorting: true,
                suppressSizeToFit: true,
                suppressMovable: true,
                suppressFilter: true,
                suppressResize: true,
                pinned: 'left'
},

Is there a callback I can use to set the selection state of a row?

Upvotes: 0

Views: 9757

Answers (1)

Bear
Bear

Reputation: 41

I needed to loop the rendered rows and select them manually after load:

this.gridApi.forEachLeafNode( (node) => {
   if (node.data.id === roleId) {
       node.setSelected(true);
   }
});

Upvotes: 3

Related Questions