Checkbox Cell Renderer

Simple renderer for boolean values that uses the standard HTML checkbox input. The renderer also allows editing.

If editing is enabled, then it is recommended to also use
the

import dash_ag_grid as dag
from dash import Dash, html

app = Dash(__name__)

rowData = [
    {
        "value1": b % 2 == 0,
        "value2": b % 2 == 0,
        "value3": b % 2 == 0,
    }
    for b in range(10)
]


columnDefs = [
    {
        "field": "value1",
        "headerName": "Disabled Checkbox",
        "cellRenderer": "agCheckboxCellRenderer",
        "cellRendererParams": {
            "disabled": True,
        },
    },
    {
        "field": "value2",
        "headerName": "With Checkbox Editor",
        "cellRenderer": "agCheckboxCellRenderer",
        "cellEditor": "agCheckboxCellEditor",
        "editable": True,
        "suppressKeyboardEvent": {"function": "params.event.key === ' '"},
    },
    {
        "field": "value3",
        "headerName": "Without Editor",
        "cellRenderer": "agCheckboxCellRenderer",
        "cellRendererParams": {
            "disabled": False,
        },
        "suppressKeyboardEvent": {"function": "params.event.key === ' '"},
    },
]


app.layout = html.Div(
    [
        dag.AgGrid(
            id="grid-checkbox-renderer",
            columnDefs=columnDefs,
            rowData=rowData,
        ),
    ],
)

if __name__ == "__main__":
    app.run(debug=True)