# Justpy Tutorial demo grid_test_checkbox1 
# Rendering Checkboxes       
#      
# generated by write_as_demo  at 2022-11-13T19:18:11.474418+00:00 
# 
# see https://justpy.io/grids_tutorial/checkbox#rendering-checkboxes
import justpy as jp

grid_options = """
{
    defaultColDef: {
        filter: true,
        sortable: true,
        resizable: true,
        cellStyle: {textAlign: 'center'},
        headerClass: 'font-bold'
    },
      columnDefs: [
      {headerName: "Make", field: "make"},
      {headerName: "Model", field: "model"},
      {headerName: "Price", field: "price"},
      {headerName: "Enabled", field: "enabled", cellRenderer: 'checkboxRenderer'}
    ],
      rowData: [
      {make: "Toyota", model: "Celica", price: 35000, enabled: false},
      {make: "Ford", model: "Mondeo", price: 32000, enabled: true},
      {make: "Porsche", model: "Boxter", price: 72000, enabled: false}
    ]
}
"""


def grid_change(self, msg):
    print(msg)


def grid_test_checkbox1():
    wp = jp.WebPage()
    grid = jp.AgGrid(a=wp, options=grid_options)
    grid.on('cellValueChanged', grid_change)
    return wp


# initialize the demo
from examples.basedemo import Demo
Demo("grid_test_checkbox1", grid_test_checkbox1)
