I have a column in ag grid of boolean type. (it’s editable column. so user can make changes).
when i edit it the alignment breaks. i dont want to pop column while editing.
column_defs= {
"headerName": value["header"],
"type": value["alignment"],
"editable": True,
"cellDataType": boolean,
"valueFormatter": {"function": "params.value ? params.value : '-'"},
"cellEditor": "agCheckboxCellEditor" if datatype == "Boolean" else None,
}```
Hi @Vaishali
Can you please provide a complete minimal example that reproduces the issue?
Here is an editable boolean column in the docs and the alignment doesn’t change
Hello @Vaishali,
My guess is it doesnt like this:
column_defs= {
"headerName": value["header"],
"type": value["alignment"],
"editable": True,
"cellDataType": boolean,
"valueFormatter": {"function": "params.value ? params.value : '-'"},
"cellEditor": "agCheckboxCellEditor" if datatype == "Boolean" else None,
}
Can you try this:
column_defs= {
"headerName": value["header"],
"type": value["alignment"],
"editable": True,
"cellDataType": "boolean"
}
@jinnyzor why are we not using valueFormatter and cellEditor. for my use case i can ignore cellEditor but i do require valueFormatter as i can have null values in this column and i want to display “-” for it. by using valueFormatted i get “-” for false value as well
as params.value receives false it think the value in params.value is not present. it displays “-”. do have any idea how to reslove this ?
@Vaishali
If a value can be one of 3 things then it’s not a boolean. I’d recommend using cellDataType: ‘text’, and handling the thee option with a cell renderer.
Hello @Vaishali,
Have you tried not passing a value formatter?
I’m assuming that there is null data that you are passing? A null, I think renders as neither false or true.
And we are using a valueFormatter, the screen shot you are providing is showing the valueFormatted
and will not display the function.
All details about the column and colDef are in keys that you didnt provide in the screenshot.
I need valueFormatter for adding “-” when params.value is null.
if i dont do that. i get invalid number on my datatable in numeric columns.
The you need to do cellDataType boolean in the column def, as I recommended here.
column_defs= {
"headerName": value["header"],
"type": value["alignment"],
"editable": True,
"cellDataType": "boolean"
}