I have searched for awhile now and haven't seen any real example of this.
I am using ag-grid-react and I would like for a column that holds a boolean to represent that boolean with a checkbox and update the object in the rowData when changed.
I know there is checkboxSelection and I tried using it like what I have below, but realized while it's a checkbox, it's not linked to the data and is merely for selecting a cell.
var columnDefs = [ { headerName: 'Refunded', field: 'refunded', checkboxSelection: true,} ]
So is there a way to do what I am looking for with ag-grid and ag-grid-react?
To configure the column to have a checkbox, set colDef. headerCheckboxSelection=true . headerCheckboxSelection can also be a function, if you want the checkbox to appear sometimes (e.g. if the column is ordered first in the grid).
Select a row by clicking on it. Selecting a row will remove previous selection unless you hold down ctrl while clicking. Selecting a row and then holding down shift while clicking a second row will select the range. Remember Row Selection works with all frameworks eg Angular and React as well as plain JavaScript.
You can enable or disable the checkbox by returning true or false from the cellRenderer function. Show activity on this post. If you're using the builtin agGroupCellRenderer to render checkbox for multiple selection, you can turn off the node's selectable flag when deciding whether to render checkbox or not.
There is no option in the library to make a single row disabled(both visually and keyboard event based), the only way we could make a single row disabled is by using a customCellRenderer for both header and subsequent cell checkboxes, this allows full control over the checkbox.
You should use the cellRenderer property
const columnDefs = [{ headerName: 'Refunded', field: 'refunded', editable:true, cellRenderer: params => { return `<input type='checkbox' ${params.value ? 'checked' : ''} />`; } }];
I was stuck in the same problem , this is the best I could come up with but I wasn't able to bind the value to this checkbox.
I set the cell property editable to true , now if you want to change the actual value you have to double click the cell and type true or false.
but this is as far as I went and I decided to help you , I know it doesn't 100% solve it all but at least it solved the data presentation part.
incase you found out how please share your answers with us.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With