enable checkbox based on column value in ag-grid

Hello, I am trying to add ag-grid table with checkbox column. Is it possible to mark checkbox as checked on bases of row value? I have tried to find the way to do this in ag-grid documentation. where I found this https://www.ag-grid.com/javascript-data-grid/row-selection/#example-displaying-disabled-checkboxes . but not sure where I can add onFirstDataRendered: (params) => { const nodesToSelect = []; params.api.forEachNode((node) => { if (node.data && node.data.year === 2012) { nodesToSelect.push(node); } }); params.api.setNodesSelected({ nodes: nodesToSelect, newValue: true }); } Can someone help me on this?
JavaScript Data Grid: Row Selection
Select a row by clicking on it. Download v30 of the best JavaScript Data Grid in the world now.
2 Replies
reenakoshta
reenakoshta10mo ago
I figured it out like this by using ag-grid api. const grid_api = getAgGrid('c').columnApi.columnModel.gridOptionsWrapper.gridOptions.api const rows = grid_api.getSelectedRows() const nodesToSelect = []; grid_api.forEachNode((node) => { if (node.data && node.data.flag === true) { nodesToSelect.push(node); node.setSelected(true); } });
Sindre
Sindre10mo ago
very nice! Thanks for updating us!